IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Traitement de l'image


Sujet :

Android

  1. #21
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Pensant que le problème pouvez venir des bibliothèques j'ai codé les quelques classe nécessaire dans mon projet mais rien y fait j'ai exactement la mm erreur lors de l'exécution de mon appli donc le problème ne vient pas de là...

    L'application fonctionne très bien jusqu'au traitement de l'image, ca me localise bien l'erreur dans le LogCat, ca me renvoie à une ligne mais il n'y a pas de problème apparant, aucun soucis. Je n'ai même pas de warning dans le programme.

  2. #22
    Expert éminent

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Points : 7 618
    Points
    7 618
    Billets dans le blog
    3
    Par défaut
    Est ce que tu pourrais coller ici l'erreur du logcat (avec la stacktrace complete), ainsi que le code de la fonction à laquelle correspond l'erreur ?
    N'oubliez pas de cliquer sur mais aussi sur si un commentaire vous a été utile !
    Et surtout

  3. #23
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Avant tout, merci de m'aider je sais que ce n'est pas évident !

    Voici le logcat complet :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    06-26 06:09:55.001: V/SimpleAndroidOCR.java(330): Starting Camera app
    06-26 06:09:56.471: W/IInputConnectionWrapper(330): showStatusIcon on inactive InputConnection
    06-26 06:10:07.610: I/SimpleAndroidOCR.java(330): onRestoreInstanceState()
    06-26 06:10:07.610: I/SimpleAndroidOCR.java(330): resultCode: -1
    06-26 06:10:07.631: V/SimpleAndroidOCR.java(330): Orient: 0
    06-26 06:10:07.631: V/SimpleAndroidOCR.java(330): Rotation: 0
    06-26 06:10:07.631: V/SimpleAndroidOCR.java(330): Before baseApi
    06-26 06:10:07.640: W/dalvikvm(330): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lcom/googlecode/tesseract/android/TessBaseAPI;
    06-26 06:10:07.640: D/AndroidRuntime(330): Shutting down VM
    06-26 06:10:07.640: W/dalvikvm(330): threadid=1: thread exiting with uncaught exception (group=0x40015560)
    06-26 06:10:07.660: E/AndroidRuntime(330): FATAL EXCEPTION: main
    06-26 06:10:07.660: E/AndroidRuntime(330): java.lang.ExceptionInInitializerError
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at mon.projet.MonProjet.onPhotoTaken(MonProjet.java:392)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at mon.projet.MonProjet.onActivityResult(MonProjet.java:316)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.Activity.dispatchActivityResult(Activity.java:3908)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:2528)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2107)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2135)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1668)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2832)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread.access$1600(ActivityThread.java:117)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.os.Handler.dispatchMessage(Handler.java:99)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.os.Looper.loop(Looper.java:123)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at android.app.ActivityThread.main(ActivityThread.java:3683)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at java.lang.reflect.Method.invokeNative(Native Method)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at java.lang.reflect.Method.invoke(Method.java:507)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at dalvik.system.NativeStart.main(Native Method)
    06-26 06:10:07.660: E/AndroidRuntime(330): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load lept: findLibrary returned null
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at java.lang.Runtime.loadLibrary(Runtime.java:429)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at java.lang.System.loadLibrary(System.java:554)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	at com.googlecode.tesseract.android.TessBaseAPI.<clinit>(TessBaseAPI.java:47)
    06-26 06:10:07.660: E/AndroidRuntime(330): 	... 18 more
    06-26 06:10:10.070: I/Process(330): Sending signal. PID: 330 SIG: 9
    Et voici le code complet de mon projet :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    package mon.projet;
     
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.text.SimpleDateFormat;
    import java.util.Date;
     
    import mon.projet.MonProjet;
    import com.googlecode.tesseract.android.TessBaseAPI;
     
    import mon.projet.R;
    import mon.projet.MonProjet.ButtonClickHandler;
     
    import android.app.Activity;
    import android.content.ContentValues;
    import android.content.Intent;
    import android.content.res.AssetManager;
    import android.graphics.Bitmap;
    import android.graphics.BitmapFactory;
    import android.graphics.Matrix;
    import android.graphics.PixelFormat;
    import android.hardware.Camera;
    import android.media.ExifInterface;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Environment;
    import android.provider.MediaStore;
    import android.provider.MediaStore.Images.Media;
    import android.util.Log;
    import android.view.SurfaceHolder;
    import android.view.SurfaceView;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.view.Window;
    import android.view.WindowManager;
    import android.widget.Button;
    import android.widget.CheckBox;
    import android.widget.CompoundButton;
    import android.widget.EditText;
    import android.widget.TabHost;
    import android.widget.TabHost.TabSpec;
    import android.widget.Toast;
     
    public class MonProjet extends Activity implements
    SurfaceHolder.Callback {
        byte code;
        String Path = "/sdcard/PhotoEditor/Test.png" ;
        Button b = null;
        private TabHost monTabHost;
    	private Camera camera;
    	private SurfaceView surfaceCamera;
    	private Boolean isPreview;
    	private FileOutputStream stream;
     
    	public static final String PACKAGE_NAME = "com.datumdroid.android.ocr.simple";
    	public static final String DATA_PATH = Environment
    			.getExternalStorageDirectory().toString() + "/SimpleAndroidOCR/";
     
    	// You should have the trained data file in assets folder
    		// You can get them at:
    		// http://code.google.com/p/tesseract-ocr/downloads/list
    		public static final String lang = "eng";
     
    		private static final String TAG = "SimpleAndroidOCR.java";
     
    		protected Button _button;
    		// protected ImageView _image;
    		protected EditText _field;
    		protected String _path;
    		protected boolean _taken;
     
    		protected static final String PHOTO_TAKEN = "photo_taken";
     
     
     
        @Override
        public void onCreate(Bundle savedInstanceState) {
     
       	 //////////////////////////////////////////////////
            ////////////////////////////////////////////
            String[] paths = new String[] { DATA_PATH, DATA_PATH + "tessdata/" };
     
    		for (String path : paths) {
    			File dir = new File(path);
    			if (!dir.exists()) {
    				if (!dir.mkdirs()) {
    					Log.v(TAG, "ERROR: Creation of directory " + path + " on sdcard failed");
    					return;
    				} else {
    					Log.v(TAG, "Created directory " + path + " on sdcard");
    				}
    			}
     
    		} 
    		if (!(new File(DATA_PATH + "tessdata/" + lang + ".traineddata")).exists()) {
    			try {
     
    				AssetManager assetManager = getAssets();
    				InputStream in = assetManager.open("tessdata/eng.traineddata");
    				//GZIPInputStream gin = new GZIPInputStream(in);
    				OutputStream out = new FileOutputStream(DATA_PATH
    						+ "tessdata/eng.traineddata");
     
    				// Transfer bytes from in to out
    				byte[] buf = new byte[1024];
    				int len;
    				//while ((lenf = gin.read(buff)) > 0) {
    				while ((len = in.read(buf)) > 0) {
    					out.write(buf, 0, len);
    				}
    				in.close();
    				//gin.close();
    				out.close();
    				Log.v(TAG, "Copied " + lang + " traineddata");
    			} catch (IOException e) {
    				Log.e(TAG, "Was unable to copy " + lang + " traineddata " + e.toString());
    			}
    		}
     
      /////////////////////////////////////////
    		/////////////////////////////////
     
     
     
            super.onCreate(savedInstanceState);
     
    		// On met l'application en plein écran et sans barre de titre
    		getWindow().setFormat(PixelFormat.TRANSLUCENT);
    		requestWindowFeature(Window.FEATURE_NO_TITLE);
    		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    				WindowManager.LayoutParams.FLAG_FULLSCREEN);
     
            isPreview = false;
     
            setContentView(R.layout.main);
     
     
     
     
            monTabHost =(TabHost) findViewById(R.id.TabHost01);
            monTabHost.setup();
     
     
            monTabHost.addTab(monTabHost.newTabSpec("onglet_1").setIndicator("Choix").setContent(R.id.Onglet1));
            monTabHost.addTab(monTabHost.newTabSpec("onglet_2").setIndicator("Résultat").setContent(R.id.Onglet2));
            monTabHost.addTab(monTabHost.newTabSpec("onglet_3").setIndicator("Scan").setContent(R.id.Onglet3));
            monTabHost.addTab(monTabHost.newTabSpec("onglet_4").setIndicator("OCR").setContent(R.id.Onglet4));
     
            monTabHost.setOnTabChangedListener(
            		new TabHost.OnTabChangeListener (){
            		public void onTabChanged(String tabId){
            			//Toast.makeText(MonProjet.this, "L’onglet avec l’identifiant : "+ tabId + " a été cliqué", Toast.LENGTH_SHORT).show();
            												}        
            											});
     
            ////////////////////////////
            ///////////////////////////
         // _image = (ImageView) findViewById(R.id.image);
         		_field = (EditText) findViewById(R.id.monEditText3);
         		_button = (Button) findViewById(R.id.button);
         		_button.setOnClickListener(new ButtonClickHandler());
     
         		_path = DATA_PATH + "/ocr.jpg";
     
     
     
         	////////////////////////
         	///////////////////////
            ((CheckBox)findViewById(R.id.CheckBox02)).setOnCheckedChangeListener(
            		new CheckBox.OnCheckedChangeListener() {
            		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            		code = 0001;
            		}
            		});
            ((CheckBox)findViewById(R.id.CheckBox03)).setOnCheckedChangeListener(
            		new CheckBox.OnCheckedChangeListener() {
            		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            		code = 0010;
            		}
            		});
            ((CheckBox)findViewById(R.id.CheckBox04)).setOnCheckedChangeListener(
            		new CheckBox.OnCheckedChangeListener() {
            		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            		code = 0011;
            		}
            		});
            ((CheckBox)findViewById(R.id.CheckBox05)).setOnCheckedChangeListener(
            		new CheckBox.OnCheckedChangeListener() {
            		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            		code = 0100;
            		}
            		});
            ((CheckBox)findViewById(R.id.CheckBox06)).setOnCheckedChangeListener(
            		new CheckBox.OnCheckedChangeListener() {
            		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            		code = 0101;
            		}
            		});
            ((CheckBox)findViewById(R.id.CheckBox07)).setOnCheckedChangeListener(
            		new CheckBox.OnCheckedChangeListener() {
            		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            		code = 0110;
            		}
            		});
            ((CheckBox)findViewById(R.id.CheckBox08)).setOnCheckedChangeListener(
            		new CheckBox.OnCheckedChangeListener() {
            		public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            		code = 0111;
            		}
            		});
            ((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
            	public void onClick(View v) {
            		String result = null;
            		EditText texte1 = ((EditText)findViewById(R.id.monEditText1));
            		String chiffre1 = texte1.getText().toString();
            		EditText texte2 = ((EditText)findViewById(R.id.monEditText2));
            		String chiffre2 = texte2.getText().toString();
     
            		switch(code){
     
            		case 0000 :
     
                    break;
            		case 0001 :
                		float somme = Float.parseFloat(chiffre1) + Float.parseFloat(chiffre2);
                		result = String.valueOf(somme);
                	break;
            		case 0010 :
                		float difference = Float.parseFloat(chiffre1) - Float.parseFloat(chiffre2);
                		result = String.valueOf(difference);
                	break;
            		case 0011 :
                		float produit = Float.parseFloat(chiffre1) * Float.parseFloat(chiffre2);
                		result = String.valueOf(produit);
                	break;
            		case 0100 :
                		float quotient = Float.parseFloat(chiffre1) / Float.parseFloat(chiffre2);
                		result = String.valueOf(quotient);
                	break;
            		case 0101 :
                		double cosinus = Math.cos(Double.parseDouble(chiffre1)*Math.PI/180);
                		result = String.valueOf(cosinus);
                	break;
            		case 0111 :
                		double sinus = Math.sin(Double.parseDouble(chiffre1)*Math.PI/180);
                		result = String.valueOf(sinus);
                	break;      	
            		}
               		Toast.makeText(MonProjet.this, result, Toast.LENGTH_LONG).show();
            		}
            	});
            // Si vous voulez gérer plusieurs caméra sur votre mobile / tablette
     		for (int nbCamera = 0; nbCamera < Camera.getNumberOfCameras(); nbCamera++) {
     			Camera.CameraInfo informationsCamera = new Camera.CameraInfo();
     			Camera.getCameraInfo(nbCamera, informationsCamera);
     
     			if (informationsCamera != null) {
     				switch (informationsCamera.facing) {
     				case Camera.CameraInfo.CAMERA_FACING_FRONT:
     					// Caméra facial
     					break;
     				case Camera.CameraInfo.CAMERA_FACING_BACK:
     					// Caméra arrière
     					break;
     				}
     			}
     		}		
    		// On récupère notre surface pour le preview 
    		surfaceCamera = (SurfaceView) findViewById(R.id.surfaceViewCamera);
    		// Quand on clique sur notre surface
    		surfaceCamera.setOnClickListener(new OnClickListener() {
     
    			public void onClick(View v) {
    				// On prend une photo
    				if (camera != null) {
    					SavePicture();
    				}
    			}
    		});
     
     
    		// Méthode d'initialisation de la caméra
    		InitializeCamera();    
        }
        public void afficheToast(String text)
        {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
        }
     
     	public class ButtonClickHandler implements View.OnClickListener {
     		public void onClick(View view) {
     			Log.v(TAG, "Starting Camera app");
     			startCameraActivity();
     		}
     	}
     
     	protected void startCameraActivity() {
    		File file = new File(_path);
    		Uri outputFileUri = Uri.fromFile(file);
     
    		final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    		intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
     
    		startActivityForResult(intent, 0);
    	}
     
     	@Override
    	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
     
    		Log.i(TAG, "resultCode: " + resultCode);
     
    		if (resultCode == -1) {
    			onPhotoTaken();
    		} else {
    			Log.v(TAG, "User cancelled");
    		}
    	}
     
     	@Override
    	protected void onSaveInstanceState(Bundle outState) {
    		outState.putBoolean(MonProjet.PHOTO_TAKEN, _taken);
    	}
     
    	@Override
    	protected void onRestoreInstanceState(Bundle savedInstanceState) {
    		Log.i(TAG, "onRestoreInstanceState()");
    		if (savedInstanceState.getBoolean(MonProjet.PHOTO_TAKEN)) {
    			onPhotoTaken();
    		}
    	}
     
    	protected void onPhotoTaken() {
    		_taken = true;
     
    		BitmapFactory.Options options = new BitmapFactory.Options();
    		options.inSampleSize = 4;
     
    		Bitmap bitmap = BitmapFactory.decodeFile(_path, options);
     
    		try {
    			ExifInterface exif = new ExifInterface(_path);
    			int exifOrientation = exif.getAttributeInt(
    					ExifInterface.TAG_ORIENTATION,
    					ExifInterface.ORIENTATION_NORMAL);
     
    			Log.v(TAG, "Orient: " + exifOrientation);
     
    			int rotate = 0;
     
    			switch (exifOrientation) {
    			case ExifInterface.ORIENTATION_ROTATE_90:
    				rotate = 90;
    				break;
    			case ExifInterface.ORIENTATION_ROTATE_180:
    				rotate = 180;
    				break;
    			case ExifInterface.ORIENTATION_ROTATE_270:
    				rotate = 270;
    				break;
    			}
     
    			Log.v(TAG, "Rotation: " + rotate);
     
    			if (rotate != 0) {
     
    				// Getting width & height of the given image.
    				int w = bitmap.getWidth();
    				int h = bitmap.getHeight();
     
    				// Setting pre rotate
    				Matrix mtx = new Matrix();
    				mtx.preRotate(rotate);
     
    				// Rotating Bitmap
    				bitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, false);
    			}
     
    			// Convert to ARGB_8888, required by tess
    			bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
     
    		} catch (IOException e) {
    			Log.e(TAG, "Couldn't correct orientation: " + e.toString());
    		}
     
    		// _image.setImageBitmap( bitmap );
     
    		Log.v(TAG, "Before baseApi");
     
    		TessBaseAPI baseApi = new TessBaseAPI();
    		baseApi.setDebug(true);
    		baseApi.init(DATA_PATH, lang);
    		baseApi.setImage(bitmap);
     
    		String recognizedText = baseApi.getUTF8Text();
     
    		baseApi.end();
     
    		// You now have the text in recognizedText var, you can do anything with it.
    		// We will display a stripped out trimmed alpha-numeric version of it (if lang is eng)
    		// so that garbage doesn't make it to the display.
     
    		Log.v(TAG, "OCRED TEXT: " + recognizedText);
     
    		if ( lang.equalsIgnoreCase("eng") ) {
    			recognizedText = recognizedText.replaceAll("[^a-zA-Z0-9]+", " ");
    		}
     
    		recognizedText = recognizedText.trim();
     
    		if ( recognizedText.length() != 0 ) {
    			_field.setText(_field.getText().toString().length() == 0 ? recognizedText : _field.getText() + " " + recognizedText);
    			_field.setSelection(_field.getText().toString().length());
    		}
     
    		// Cycle done.
    	}
     
     
    	public void InitializeCamera() {
    		// On attache nos retour du holder à notre activite
    		surfaceCamera.getHolder().addCallback(this);
     
    		// On spécifie le type du holder en mode SURFACE_TYPE_PUSH_BUFFERS
    		surfaceCamera.getHolder().setType(
    				SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    	}
     
    	// Retour sur l'application
    	@Override
    	public void onResume() {
    		super.onResume();
    		camera = Camera.open();
    		camera.setDisplayOrientation(90);
    	}
     
    	// Mise en pause de l'application
    	@Override
    	public void onPause() {
    		super.onPause();
     
    		if (camera != null) {
    			camera.release();
    			camera = null;
    		}
    	}
     
    	// Implémentation du surface holder
     
    	// Quand la surface change
    	public void surfaceChanged(SurfaceHolder holder, int format, int width,
    			int height) {
     
    		// Si le mode preview est lancé alors on le stop
    		if (isPreview) {
    			camera.stopPreview();
    		}
    		// On récupère les parametres de la camera
    		Camera.Parameters parameters = camera.getParameters();
     
    		// On change la taille
    		parameters.setPreviewSize(width, height);
     
    		// On applique nos nouveaux parametres
    		camera.setParameters(parameters);
     
    		try {
    			// On attache notre previsualisation de la camera au holder de la
    			// surface
    			camera.setPreviewDisplay(surfaceCamera.getHolder());
    		} catch (IOException e) {
    		}
     
    		// On lance la previeuw
    		camera.startPreview();
     
    		isPreview = true;
    	}
     
    	public void surfaceCreated(SurfaceHolder holder) {
    		// On prend le controle de la camera
    		if (camera == null)
    			camera = Camera.open();
    	}
     
    	public void surfaceDestroyed(SurfaceHolder holder) {
    		// On arrête la camera et on rend la main
    		if (camera != null) {
    			camera.stopPreview();
    			isPreview = false;
    			camera.release();
    		}
    	}
     
    	// Callback pour la prise de photo
    	Camera.PictureCallback pictureCallback = new Camera.PictureCallback() {
     
    		public void onPictureTaken(byte[] data, Camera camera) {
    			if (data != null) {
    				// Enregistrement de votre image
    				try {
    					if (stream != null) {
    						stream.write(data);
    						stream.flush();
    						stream.close();
    					}
    				} catch (Exception e) {
    					// TODO: handle exception
    				}
     
    				// On redémarre la prévisualisation
    				camera.startPreview();
    			}
    		}
    	};
     
    	private void SavePicture() {
    		try {
    			SimpleDateFormat timeStampFormat = new SimpleDateFormat(
    					"yyyy-MM-dd-HH.mm.ss");
    			String fileName = "photo_" + timeStampFormat.format(new Date())
    					+ ".jpg";
     
    			// Metadata pour la photo
    			ContentValues values = new ContentValues();
    			values.put(Media.TITLE, fileName);
    			values.put(Media.DISPLAY_NAME, fileName);
    			values.put(Media.DESCRIPTION, "Image prise par FormationCamera");
    			values.put(Media.DATE_TAKEN, new Date().getTime());
    			values.put(Media.MIME_TYPE, "image/jpeg");
     
    			// Support de stockage
    			Uri taken = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,
    					values);
     
    			// Ouverture du flux pour la sauvegarde
    			stream = (FileOutputStream) getContentResolver().openOutputStream(
    					taken);
     
    			camera.takePicture(null, pictureCallback, pictureCallback);
    		} catch (Exception e) {
    			// TODO: handle exception
    		}
     
    	}
     
    }
    Quand je clique sur l'erreur du logcat, ca me renvoit sur la ligne 392, alors que tout est normal, je n'ai aucune erreur puisque je peux compiler.

    Je suis un nouveau en programmation android, j'apprends jour après jour, je pensais qu'il y'avait un problème de lecture dans une bibliothèque alors j'avais mis la fonction où il y'a l'erreur directement dans mon programme, mais il y'avait quand même cette même erreur.

    Je sens que je suis à 2 doigts de faire fonctionner cet OCR, je suis très content que vous m'aidiez à avancer!

  4. #24
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 592
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 592
    Points : 18 498
    Points
    18 498
    Par défaut
    Si il y a une ExceptionInInitializerError à la ligne 392 de MonProjet.java c'est à cause de la UnsatisfiedLinkError à la ligne 47 de TessBaseAPI.java.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Caused by: java.lang.UnsatisfiedLinkError: Couldn't load lept: findLibrary returned null
    Il y a un problème avec une librairie.
    Keith Flint 1969 - 2019

  5. #25
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Bien vue,

    Enfait je regarde dans TessBaseApi.java et il y'a ca :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    static {
    System.loadLibrary("lept");
    System.loadLibrary("tess");
     
    nativeClassInit();
    }
    Sachant que TessBaseApi.java c'est quelque chose que j'ai choppé sur le net, faut que je trouve ces library alors ? Et une fois que je les ai je dois les mettre ou ?

    C'est quand même étrange puisque j'ai bien mis tess-two en librairie :s !

  6. #26
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 592
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 592
    Points : 18 498
    Points
    18 498
    Par défaut
    Tu n'as qu'a suivre ce genre de tuto, tout est expliqué pas à pas :
    http://gaut.am/making-an-ocr-android...ing-tesseract/

    Si tu ne comprends pas l'anglais, laisse tomber l'informatique tout de suite.
    Keith Flint 1969 - 2019

  7. #27
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    C'est ma page de référence !

    Je viens de lire tout les commentaires et beaucoups de personne utilisant windows ont le soucis des bibliothèque manquante lept et tess.

    Je cherche un moyen de résoudre ce problème mais d'après ces personnes il parait sans solution, bien que des personnes ont réussi à faire cet OCR sans problème sur windows.

  8. #28
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 592
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 592
    Points : 18 498
    Points
    18 498
    Par défaut
    Bon déjà est-ce que t'as fais ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    cd <project-directory>/tess-two
    ndk-build
    android update project --path .
    ant release
    Moi j'ai ajouté le dossier android-ndk-r7c au PATH (il y a un fichier ndk-build.cmd dedans).
    Je suis allé dans tess-two et en faisant ndk-build ça me fait des centaines de lignes comme ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    "Compile thumb : lept <= colorquant1.c
    "Compile thumb : lept <= colorquant2.c
    "Compile thumb : lept <= colorseg.c
    "Compile thumb : lept <= colorspace.c
    "Compile thumb : lept <= compare.c
    "Compile thumb : lept <= conncomp.c
    "Compile thumb : lept <= convertfiles.c
    "Compile thumb : lept <= convolve.c
    "Compile thumb : lept <= convolvelow.c
    "Compile thumb : lept <= correlscore.c
    "Compile thumb : lept <= dewarp.c
    "Compile thumb : lept <= dwacomb.2.c
    "Compile thumb : lept <= dwacomblow.2.c
    "Compile++ thumb : lept <= box.cpp
    "Compile++ thumb : lept <= pix.cpp
    "Compile++ thumb : lept <= pixa.cpp
    "Compile++ thumb : lept <= utilities.cpp
    "Compile++ thumb : lept <= readfile.cpp
    "Compile++ thumb : lept <= writefile.cpp
    "Compile++ thumb : lept <= jni.cpp
    Prebuilt       : libgnustl_static.a <= <NDK>/sources/cxx-stl/gnu-libstdc++/libs/
    armeabi/
    SharedLibrary  : liblept.so
    Install        : liblept.so => libs/armeabi/liblept.so
    "Compile++ thumb : tess <= baseapi.cpp
    "Compile++ thumb : tess <= adaptions.cpp
    "Compile++ thumb : tess <= applybox.cpp
    "Compile++ thumb : tess <= control.cpp
    "Compile++ thumb : tess <= cube_control.cpp
    Ça a commencé ya un bail et c'est toujours pas fini.

    T'as le dossier libs avec dedans le dossier armeabi avec des .so dedans ?
    Keith Flint 1969 - 2019

  9. #29
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Je n'ai pas mon PC à disposition là, je testerai ce soir en rentrant chez moi.

    Je te dirai ce qu'il en est !

  10. #30
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 592
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 592
    Points : 18 498
    Points
    18 498
    Par défaut
    Le problème vient de là.
    Le logcat t'indique qu'il ne ne trouve pas ta librairie, c'est du au fait que tu n'as pas la librairie.
    Keith Flint 1969 - 2019

  11. #31
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    C'est étrange car je me sers de tess-two comme librairie, qui lui possède normalement ces 2 librairies lept et tess.

    Mais je ne trouve pas ces librairies, et je ne sais pas ou les chercher surtout, j'ai pas mal googlé ce matin en vain.

  12. #32
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 592
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 592
    Points : 18 498
    Points
    18 498
    Par défaut
    Tu dois les compiler, c'est tout.

    Il faut juste que tu ais ndk-build.cmd après c'est bon.
    Tu as une seule commande à rentrer et t'attends que ça compile.
    Keith Flint 1969 - 2019

  13. #33
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    J'ai android-ndk-r8 mais le problème c'est que je sais pas l'installer convenablement encore car j'ai des soucis avec Cygwin et d'après ce que j'ai compris je suis obligé de passé par là !

    Je ne sais pas si y'a des soucis de compatibilité entre Cygwin et windows 7 mais aucune commande n'est reconnu alors qu'elle sont toute bien installer, la seule commande qui fonctionne c'est exit. Pour ca je pense retenté chez moi en installer avec internet et pas avec des packages chopé comme ca.

    Quand tu dis que tu as ajouté le ndk au PATH tu as ajouté quoi et ou exactement ?

    Tout le contenu du dossier ndk dans tess two ?

  14. #34
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 592
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 592
    Points : 18 498
    Points
    18 498
    Par défaut
    Dans les paramètres système avancés de Windows 7 => variables d'environnement => Variable "PATH" là j'ai ajouté l'adresse où se trouve le fichier cmd qu'il faut bien et après depuis l'invite de commandé la commande est reconnu.

    Sinon j'aurais pu aller dans le dossier où se situe le .cmd et l’exécuter depuis là mais j'aurais du mettre toute l'adresse du dossier tess-two.
    Ou alors j'aurais pu aller dans le dossier et mettre toute l'adresse de la commande.

    Mais bon c'était plus simple de ne pas avoir à gérer l'adresse de la commande.
    Keith Flint 1969 - 2019

  15. #35
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Encore une fois bien vu,

    Mm manip que pour le SDK enfait, la commande est bien reconnu, ca me fait toute les lignes dont tu m'a parlé !

    Une fois que ce sera fait, ces 2 bibliothèque seront donc créer ? Faudra que je les référence ou le system.loadlibrary suffira pour allez les chercher ?

    Edit : voila ca a fini de faire toutes les lignes, j'ai tenté de faire les commandes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    android update project --path .
    ant release
    mais elles ne sont pas reconnues.

    En tout cas les bibliothèques sont bien créée mais quand je les ajoute en fesant clique droit, propriété, build java path , add jars, mon projet se met en erreur, et pourtant aucune erreur n'existe dedans.


    Edit edit: j'ai l'impression que ca fonctionne je vous tiens au courant.

  16. #36
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Alors je reviens aux nouvelles !

    Ca à l'air de fonctionner sur AVD bien que je ne puisse pas vraiment testé puisque ma webcam n'est pas reconnue, mais au moins je récupère quelque chose dans l'edit text !

    En revanche, j'ai exporté en .apk et sur mon portable, soit l'apply se ferme ( sans erreur ) soit je retourne bien sur l'appli mais avec rien dans l'edit text.

    Cependant, au moment de l'exportation en .apk, j'ai toujours cette "erreur" :



    Mais ca me crée bien le .apk, j'ai vérifié c'est le bon !

    Encore merci à vous de m'aider !

    Edit : L'erreur est résolue, j'ai juste ajouté un dossier res dans tess-two, par contre l'apply bug tjs sur téléphone. J'ai pensais que le path vers ma photo était mauvaise, alors j'ai mis une image et un path fix, rien a voir avec la photo que je dois faire mais toujours rien. Mon AVD est en version 2.3.3 et mon téléphone en 2.3.6, ca peut jouer ?

  17. #37
    Modérateur
    Avatar de Hizin
    Homme Profil pro
    Développeur mobile
    Inscrit en
    Février 2010
    Messages
    2 180
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur mobile

    Informations forums :
    Inscription : Février 2010
    Messages : 2 180
    Points : 5 072
    Points
    5 072
    Par défaut
    Tu package bien tes bibliothèques avec l'application ? Tu ne les laisses pas "en dehors" en faisant juste un linkage vers un chemin absolu ?
    C'est Android, PAS Androïd, ou Androïde didiou !
    Le premier est un OS, le second est la mauvaise orthographe du troisième, un mot français désignant un robot à forme humaine.

    Membre du comité contre la phrase "ça marche PAS" en titre et/ou explication de problème.

    N'oubliez pas de consulter les FAQ Android et les cours et tutoriels Android

  18. #38
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Euh package ? Enfait je met tess-two is library, ensuite je dis a monprojet d'utiliser tess-two comme library, je dois faire + pour les liés d'après toi ? Comment ?

  19. #39
    Membre extrêmement actif
    Avatar de Ryu2000
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2008
    Messages
    9 592
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 36
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Décembre 2008
    Messages : 9 592
    Points : 18 498
    Points
    18 498
    Par défaut
    Dans le Build Path fait Add Library -> Android classpath container -> tess-two.

    Essaie de lancer l'application sur ton téléphone directement depuis Eclipse.
    Keith Flint 1969 - 2019

  20. #40
    Membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2012
    Messages
    127
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Santé

    Informations forums :
    Inscription : Janvier 2012
    Messages : 127
    Points : 56
    Points
    56
    Par défaut
    Oui en fesant avec ta façon pour ajouter tess-two comme library ca me met une erreur qu'elle existe déjà dans le projet donc je l'avais bien ajouté.

    Par contre je n'ai pas de câble à disposition pour lancer directement depuis eclipse donc je suis obligé de passé par apk.
    Images attachées Images attachées  

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 3 PremièrePremière 123 DernièreDernière

Discussions similaires

  1. Projet - Visualiser le traitement d'une image
    Par genzo93 dans le forum 2D
    Réponses: 4
    Dernier message: 03/05/2007, 17h12
  2. Projet de traitement automatique d'image
    Par sonsons dans le forum Images
    Réponses: 8
    Dernier message: 25/01/2007, 12h37
  3. Traitement automatique d'image
    Par zzaza dans le forum Images
    Réponses: 7
    Dernier message: 20/01/2007, 16h03
  4. Par où commencer en traitement de l'image et/ou du son
    Par PRomu@ld dans le forum Traitement du signal
    Réponses: 4
    Dernier message: 08/12/2005, 15h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo