Android Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsMobile ProgrammingAndroid Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 27th, 2013, 10:52 AM
silvestr2 silvestr2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 1 silvestr2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 m 57 sec
Reputation Power: 0
OCR, placing recognized text on camera view

I am trying to print the recognized text on the camera view. I am getting this error:

Can't create handler inside thread that has not called Looper.prepare()

I done some research about this problem, but even though i can not fox it probably because of luck of experience (first time I try to build an app using openCV and tesseract, I am encountering many errors i have not seen before). Please be lenient. My piece of the code in which i want to use Toast is added below:

Code:
import android.content.Context;
import android.graphics.Bitmap;
import org.opencv.core.Mat;
import android.os.Environment;

import android.util.Log;
import android.widget.Toast;

import com.googlecode.tesseract.android.TessBaseAPI;

public class justOCR {
    Bitmap bitmap;
    protected Context context;

    public justOCR(Context context){
        this.context = context;
    }

        public static final String DATA_PATH = Environment
                .getExternalStorageDirectory().toString() + "/sdcard/CameraTest/";
        private static final String lang = null;

    public void numPlateOCR(Mat plate){ 

        bitmap=Bitmap.createBitmap(plate.width(), plate.height(), Bitmap.Config.ARGB_8888);
        org.opencv.android.Utils.matToBitmap(plate, bitmap);
        bitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);
        // Convert to ARGB_8888, required by tess
        //byteArray = byteArray.copy(Bitmap.Config.ARGB_8888, true);


    // _image.setImageBitmap( bitmap );

    Log.v("baseApi", "Before baseApi");

    TessBaseAPI baseApi = new TessBaseAPI();
    baseApi.setDebug(true);
    //baseApi.init(DATA_PATH, lang);
    baseApi.init("/sdcard/CameraTest/", "eng");
    baseApi.setVariable("tessedit_char_whitelist", "1234567890");
    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("NUMBER", "OCRED TEXT: " + recognizedText);

    //if ( lang.equalsIgnoreCase("eng") ) {
    //  recognizedText = recognizedText.replaceAll("[^a-zA-Z0-9]+", " ");
    //}

    recognizedText = recognizedText.trim();

    if ( recognizedText.length() != 0 ) {
        //TODO print or save to xml//

        Toast.makeText(this.context, "***"+recognizedText+"***", Toast.LENGTH_SHORT).show();

    }
}

}


Thank you for any help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsMobile ProgrammingAndroid Development > OCR, placing recognized text on camera view

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap