Ask Your Question

nadia's profile - activity

2019-04-22 00:04:10 -0500 received badge  Popular Question (source)
2018-06-28 02:45:18 -0500 received badge  Notable Question (source)
2017-09-14 14:31:18 -0500 received badge  Popular Question (source)
2017-08-02 17:18:20 -0500 received badge  Popular Question (source)
2016-11-30 12:15:04 -0500 commented question SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java for android

I am sorry for the disturbance but i have an other question. which types of texture or shape descriptors opencv can use

2016-11-30 09:53:49 -0500 commented question SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java for android

Concerning BOW is it supported by java ?

2016-11-30 09:27:58 -0500 commented question SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java for android

i put my code. Can you help me

2016-11-30 08:11:49 -0500 asked a question SURF and SIFT algorithms doesn't work in OpenCV 3.0 Java for android

I tried to use Sift or surf descriptors for machine learning in an android application. But when i run the program i get this error.

OpenCV Error: Bad argument (Specified feature detector type is not supported.) in cv::javaFeatureDetector::create

My code:

public   void train() {

 // Creating Training Data
   Mat trainData = new Mat();
  Mat train_labels = new Mat();

     Mat descriptors ;
    FeatureDetector featureDetector;
     MatOfKeyPoint keyPoints;
     DescriptorExtractor descriptorExtractor;
Mat descriptors1 ;
FeatureDetector featureDetector1;
MatOfKeyPoint keyPoints1;
DescriptorExtractor descriptorExtractor1;


    String Newligne=System.getProperty("line.separator");


  for (int i = 0; i <48; i++) {

   String path1 = Environment.getExternalStorageDirectory().toString()
   + "/Pictures/images/" + "a"+i + ".jpg";
     /* String path1 = Environment.getExternalStorageDirectory().toString()
        + "/Pictures/images/" +"a"+ i + ".jpg";*/

     Mat img = Imgcodecs.imread(path1);
featureDetector=FeatureDetector.create(FeatureDetector.PYRAMID_FAST);
descriptorExtractor=DescriptorExtractor.create(DescriptorExtractor.SIFT);
keyPoints = new MatOfKeyPoint();
descriptors = new Mat();
featureDetector.detect(img, keyPoints);
Log.d("LOG!", "number of query Keypoints= " + keyPoints.size());
// Descript keypoints
descriptorExtractor.compute(img, keyPoints, descriptors);
Log.d("LOG!", "number of descriptors= " + descriptors.size());

     Log.i(TAG,"error"+i+img.empty());


         trainData.push_back(descriptors)// add 1 item
        train_labels.push_back(new Mat(1, 1, CvType.CV_32SC1, new Scalar(i)));

         }
2016-06-04 04:51:58 -0500 commented question How to normalize image with opencv and java

I don't know what normalization means exactly but i want to find a solution for theses"interpolation of some kind".

2016-06-04 01:57:00 -0500 commented question How to normalize image with opencv and java

if i will resize the image i think that some informations from the image will change or will deleted so i thinked to normalized the image to preserve all informations and to get the identical image but with a smaller size or bigger size

2016-06-03 16:38:18 -0500 asked a question How to normalize image with opencv and java

I want to normalize an image using opencv and java before resizing it (changing size will make some changes in the image so i should normalized it this is the reason for choosing normalization).How can i proceed please. Thanks in advance

2016-05-30 14:18:38 -0500 asked a question Neural network implementation using opencv and java

I should use opencv with java language but when i tried to implement neural network i got errors in this instruction ann.train(trainData, Ml.ROW_SAMPLE,train_labels);

        // Creating Training Data
                Mat trainData = new Mat();
        Mat train_labels = new Mat();

                for (int i = 0; i <5; i++) {


                String path = Environment.getExternalStorageDirectory().toString()
                        + "/Pic/folder/" + i + ".png";

                Mat img = Imgcodecs.imread(path);

                img.convertTo(img, CvType.CV_32FC1); // Convert to float
                Size dsize = new Size(25, 25);
                Imgproc.resize(img, img, dsize);

                img.convertTo(img, CvType.CV_32FC1);
                Mat imgResized = img.reshape(1, 1); // make continuous

                trainData.push_back(imgResized);
                // add 1 item
                train_labels
                        .push_back(new Mat(1, 1, CvType.CV_32SC1, new Scalar(0)));

            }
                for (int i = 6; i <15; i++) {


                    String path = Environment.getExternalStorageDirectory().toString()
                            + "/Pictures/train/" + i + ".png";

                    Mat img = Imgcodecs.imread(path);



                    img.convertTo(img, CvType.CV_32FC1); // Convert to float
                    Size dsize = new Size(25, 25);
                    Imgproc.resize(img, img, dsize);

                    img.convertTo(img, CvType.CV_32FC1);
                    Mat imgResized = img.reshape(1, 1); // make continuous

                    trainData.push_back(imgResized);
                    // add 1 item
                    train_labels
                            .push_back(new Mat(1, 1, CvType.CV_32SC1, new Scalar(1)));

                }

                Mat response = new Mat();
                Mat tmp;
                tmp = train_labels.reshape(1, 1); // make continuous
                tmp.convertTo(response, CvType.CV_32FC1); // Convert to float
                 ANN_MLP ann=ANN_MLP.create();

                    TermCriteria criteria = new TermCriteria(TermCriteria.EPS +TermCriteria.MAX_ITER,100,0.1);
                    ann.setTermCriteria(criteria);
                    ann.train(trainData, Ml.ROW_SAMPLE,train_labels);

this is the error: 05-30 19:40:20.003: E/cv::error()(12928): OpenCV Error: Unspecified error (The network has not been created. Use method create or the appropriate constructor) in void cv::ml::ANN_MLPImpl::prepare_to_train(const cv::Mat&, const cv::Mat&, cv::Mat&, int), file /home/maksim/workspace/android-pack/opencv/modules/ml/src/ann_mlp.cpp, line 661

2016-04-28 11:41:43 -0500 commented question opencv error when trying to submat an image in an android project

The error is at the end of the code (i delete the first submat at the begining ).it seems like an infinite loop .i found all the "su" mat stored in Lignes directory but the application stopped. My aim here is to sort extracted rect ligne per ligne and for each ligne i should sort the rect in the x axis.

2016-04-27 08:55:00 -0500 asked a question opencv error when trying to submat an image in an android project

I tried to detect contours in an image ,draw a bounding box for each contours ,put all rect.x rect.y rect.height in an array lists ,sorting them and finally draw a rectangle for each lignes in the image .but i got this error(the error is here : Imgcodecs.imwrite("/storage/emulated/0/DCIM/Lignes/sub"+j+".png",su);

04-27 14:33:43.818: E/cv::error()(25787): OpenCV Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) in cv::Mat::Mat(const cv::Mat&, const cv::Range&, const cv::Range&), file /home/maksim/workspace/android-pack/opencv/modules/core/src/matrix.cpp, line 456

    if (approxDistance >1.5){

            Imgproc.rectangle(gray, new Point(rect.x-3,rect.y-3), new Point(rect.x+rect.width+5,rect.y+5+rect.height), new Scalar(0,0,0),2);   



         //Ajouter les colonnes dans un tableau
           valx.add(rect.x);
          for(int p=0; p<valx.size(); p++){

              System.out.println("colx = " + valx.get(p));
               }

          k1++;



          //Ajouter les lignes dans un tableau

          valy.add(rect.y);
        for(int p=0; p<valy.size(); p++){
       System.out.println(" coly = " + valy.get(p));
       }   

        //Ajouter les hauteur des bounding boxes


        hauteur.add(rect.height);
        for(int p=0; p<valy.size(); p++){
       System.out.println(" hauteur = " + hauteur.get(p));
       } 


//Ajouter les largeurs des bounding boxes


        largeur.add(rect.width);
        for(int p=0; p<valx.size(); p++){
       System.out.println(" largeur = " + hauteur.get(p));
       } 
          //trier les colonnes

       if(k1==valx.size()){
           Collections.sort(valx);
           for(int p=0; p<valx.size(); p++){
               System.out.println("colx trié"+ valx.get(p));
               }
       }


       //trier les lignes

         if(k1==valy.size()){
            Collections.sort(valy);


            for(int p=0; p<valy.size(); p++){
            System.out.println("coly trié"+ valy.get(p));   



          }
         }




         //trier les hauteurs
         if(k1==hauteur.size()){
           Collections.sort(hauteur);
             for(int p=0; p<hauteur.size(); p++){
                 System.out.println("hauteur trié"+hauteur.get(p));
                 }
         }

         //trier les largeurs

         if(k1==largeur.size()){
               Collections.sort(largeur);
               for(int p=0; p<largeur.size(); p++){
                   System.out.println("largeur trié"+hauteur.get(p));
                   }
           } 






       }

        count=k1;


       }

      Log.i(TAG,"nombre de lettres"+ count);
      int x=hauteur.get(hauteur.size()-1)-2;
      int y=largeur.get(largeur.size()-1)-2; 

      int j=0;
    for(int k=valy.get(0);k<gray.height();k=k+x)
      {

    Imgproc.rectangle(gray, new Point(valx.get(0),k), new Point(gray.width(),k+x+2), new Scalar(255,0,0),2);
    Mat su = gray.submat(k,k+x+2,valx.get(0),gray.width());

   //  Mat su = gray.submat(k,k+x,valx.get(0),gray.width());
      Log.i(TAG,"erreur1");

      Imgcodecs.imwrite("/storage/emulated/0/DCIM/Lignes/sub"+j+".png",su);
      Log.i(TAG,"erreur2");

         j++;
       }
2016-04-20 09:15:42 -0500 asked a question How to sort bounding boxes in x-axis with java and android

I succeed to find contours and drawing bounding boxes but when i extract the letters in the bounding boxes they was saved randomly .Is there a method that order bounding boxes from left to right .this is my code :

      //find and draw contours:
     List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
       Mat hierarchy = new Mat();
       Imgproc.findContours(gray, contours, hierarchy, Imgproc.RETR_TREE,Imgproc.CHAIN_APPROX_SIMPLE);
       for (int contourIdx = 0; contourIdx < contours.size(); contourIdx++) {

       Imgproc.drawContours(gray, contours, contourIdx, new Scalar(255,0,0),6);

       }

     MatOfPoint2f approxCurve = new MatOfPoint2f();
       //For each contour found
     int k=0;
       for (int i=0; i<contours.size(); i++)
       {



           //Convert contours(i) from MatOfPoint to MatOfPoint2f
           MatOfPoint2f contour2f = new MatOfPoint2f( contours.get(i).toArray() );
           //Processing on mMOP2f1 which is in type MatOfPoint2f
           double approxDistance = Imgproc.arcLength(contour2f, true)*0.02;
           Imgproc.approxPolyDP(contour2f, approxCurve, approxDistance, true);

           //Convert back to MatOfPoint
           MatOfPoint points = new MatOfPoint( approxCurve.toArray() );

           // Get bounding rect of contour
           Rect rect = Imgproc.boundingRect(points);

           // draw enclosing rectangle (all same color, but you could use variable i to make them unique)
       if (approxDistance >1.5){
           Imgproc.rectangle(gray, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar(255,0,0),2);

           Mat ROI = gray.submat(rect.y, rect.y + rect.height, rect.x, rect.x + rect.width);

           Imgproc.resize(ROI,ROI, new Size(25,25) );
           Imgcodecs.imwrite("/storage/emulated/0/DCIM/camera/image"+p+".png",ROI);
           p++;

        }
        count=p;

       }
2016-04-05 09:02:44 -0500 commented question how to find all the objects in the picture with one template using opencv and java for android

I edit it :) Can you help me please

2016-04-05 08:33:39 -0500 asked a question how to find all the objects in the picture with one template using opencv and java for android

i tried to do a code that find all objects using a template .The logCat don't give me any errors but the application stopped this is the code .Please help me

public Mat matchTemplate(String inFile, String templateFile,String outFile, int match_method) {
    Log.i(TAG, "Running Template Matching");

    Mat img = Imgcodecs.imread(inFile);

    Mat templ = Imgcodecs.imread(templateFile);




    // / Create the result matrix
    int result_cols = img.cols() - templ.cols() + 1;
    int result_rows = img.rows() - templ.rows() + 1;
    Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
    Log.i(TAG,"error debug: "+result.empty());

    // / Do the Matching Normalize and Perform the template matching operation
    Imgproc.matchTemplate(img, templ, result, match_method);
  //   Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());
     Imgproc.threshold(result, result,0.8,1,Imgproc.THRESH_TOZERO);    

 // / Localizing the best match with minMaxLoc. We localize the minimum and maximum values in the result matrix R by using minMaxLoc.
     Point matchLoc;
     Point maxLoc;
     Point minLoc;

     MinMaxLocResult mmr;

     boolean iterate = true;
     while(true){

     // / Localizing the best match with minMaxLoc
     mmr = Core.minMaxLoc(result);
     matchLoc = mmr.maxLoc;


     if(mmr.maxVal >=0.9)
     {
       //  iterate = false;




    // / Show me what you got

    Imgproc.rectangle(img, matchLoc, new Point(matchLoc.x + templ.cols(),matchLoc.y + templ.rows()), new Scalar(0,0,0));
     }
      else
         break; //No more results within tolerance, break search
 }
    // Save the visualized detection.
    Log.i(TAG, "Writing: " + outFile);

    Imgcodecs.imwrite(outFile, img);
    return img;

}
2016-04-04 11:34:55 -0500 asked a question matching one template with multiple object with opencv and java for android

i tried to do a code that find all objects using a template .The logCat don't give me any errors but the application stopped this is the code .Please help me

public Mat matchTemplate(String inFile, String templateFile,String outFile, int match_method) {
Log.i(TAG, "Running Template Matching");

Mat img = Imgcodecs.imread(inFile);

Mat templ = Imgcodecs.imread(templateFile);




// / Create the result matrix
int result_cols = img.cols() - templ.cols() + 1;
int result_rows = img.rows() - templ.rows() + 1;
Mat result = new Mat(result_rows, result_cols, CvType.CV_32FC1);
Log.i(TAG,"error debug: "+result.empty());

       // / Do the Matching Normalize and Perform the template matching operation
      Imgproc.matchTemplate(img, templ, result, match_method);
    //   Core.normalize(result, result, 0, 1, Core.NORM_MINMAX, -1, new Mat());
 Imgproc.threshold(result, result,0.8,1,Imgproc.THRESH_TOZERO);    

         // / Localizing the best match with minMaxLoc. We localize the minimum and maximum values in the result matrix R by using minMaxLoc.
 Point matchLoc;
 Point maxLoc;
 Point minLoc;

 MinMaxLocResult mmr;

 boolean iterate = true;
      while(true){

 // / Localizing the best match with minMaxLoc
 mmr = Core.minMaxLoc(result);
 matchLoc = mmr.maxLoc;


        if(mmr.maxVal >=0.9)
     {
   //  iterate = false;




      // / Show me what you got

      Imgproc.rectangle(img, matchLoc, new Point(matchLoc.x + templ.cols(),matchLoc.y + templ.rows()), new    Scalar(0,0,0));
 }
  else
     break; //No more results within tolerance, break search
     }
// Save the visualized detection.
Log.i(TAG, "Writing: " + outFile);

Imgcodecs.imwrite(outFile, img);
return img;

}
2016-04-02 18:57:12 -0500 asked a question android opencv template matching error

I tested an android application for template matching using opencv and java from this link link text but when i run it i got theses errors

image description

How can i resolve them

2016-04-02 11:53:03 -0500 commented answer android opencv template matching error

i am sorry but what you mean by " you have to actively load the native so's" and i have opencv manager app installed and where exactly i should move them .i am really sorry but i am a beginner in opencv and android

2016-04-02 11:34:40 -0500 commented answer android opencv template matching error

i am sorry but i add all the native libs to libs folder under my project and i put the 3 pictures under res /drawable-mdpi (the picture are png forms) and i run the app there no error but the app stopped

2016-04-02 10:23:25 -0500 commented question android opencv template matching error

i add the logout error and there is an other error cannot load opencv library I try this also it doesnt work http://stackoverflow.com/questions/17...

2016-04-02 10:10:53 -0500 asked a question android opencv template matching error

I found this code and when i run it a lot of errors occured.

04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor mIsFloating : false 04-02 17:04:42.614: D/PhoneWindow(9887): FMB installDecor flags : 8454400 04-02 17:04:42.614: D/OpenCV/StaticHelper(9887): Trying to get library list 04-02 17:04:42.624: E/OpenCV/StaticHelper(9887): OpenCV error: Cannot load info library for OpenCV 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Library list: "" 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): First attempt to load libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to init OpenCV libs 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Trying to load library opencv_java3 04-02 17:04:42.624: D/OpenCV/StaticHelper(9887): Cannot load library "opencv_java3" 04-02 17:04:42.624: W/System.err(9887): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.example.match-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]] couldn't find "libopencv_java3.so" 04-02 17:04:42.624: W/System.err(9887): at java.lang.Runtime.loadLibrary(Runtime.java:366) 04-02 17:04:42.624: W/System.err(9887): at java.lang.System.loadLibrary(System.java:989) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.loadLibrary(StaticHelper.java:64) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCVLibs(StaticHelper.java:95) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.StaticHelper.initOpenCV(StaticHelper.java:39) 04-02 17:04:42.624: W/System.err(9887): at org.opencv.android.OpenCVLoader.initDebug(OpenCVLoader.java:77) 04-02 17:04:42.624: W/System.err(9887): at com.example.match.MainActivity.onCreate(MainActivity.java:23) 04-02 17:04:42.624: W/System.err(9887): at android.app.Activity.performCreate(Activity.java:6374) 04-02 17:04:42.624: W/System.err(9887): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.access$900(ActivityThread.java:181) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482) 04-02 17:04:42.624: W/System.err(9887): at android.os.Handler.dispatchMessage(Handler.java:102) 04-02 17:04:42.624: W/System.err(9887): at android.os.Looper.loop(Looper.java:145) 04-02 17:04:42.624: W/System.err(9887): at android.app.ActivityThread.main(ActivityThread.java:6145) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Native Method) 04-02 17:04:42.624: W/System.err(9887): at java.lang.reflect.Method.invoke(Method.java:372) 04-02 17:04:42.624: W/System.err(9887): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller ... (more)

2016-04-01 07:09:12 -0500 asked a question Comparing bounding box with an image from sqlite database

I would do a part of an android application that compare image in bounding bow with images in sqlite database and if it finds an image that looks like one of the images in the database it will write the name of the image (with this function "Imgproc.putText(....) ").I think that i can use template matching but i don't know how Can someone help me

2016-03-28 05:21:27 -0500 commented question how can i use opencv to compare charaters in a picture and characters in a database

:( i search a lot in the internet but i don't find any android example that use opencv machine learning for letters recognition .I search since 3 days but i don't found .Can you help me please

2016-03-28 05:12:53 -0500 commented question how can i use opencv to compare charaters in a picture and characters in a database

i am sorry i resolve it because i import android.graphics.Rect; instead of org.opencv.core.Rect;

2016-03-28 05:08:04 -0500 commented question how can i use opencv to compare charaters in a picture and characters in a database

yes ,i use opencv 3.1.0 !!

2016-03-28 05:00:24 -0500 commented question how can i use opencv to compare charaters in a picture and characters in a database

how can i implement this example .i just copied the code into my activity (error in this instruction " Mat num = digits.submat(new Rect(c20,r20,20,20));" submat isn't known ).What are the steps that i should follow to try this example

2016-03-25 06:55:30 -0500 commented question how can i use opencv to compare charaters in a picture and characters in a database

I use opencv 3.1.0 for android

I create a database that contains for each letter its equivalents in latin language

I seperate my characters in my image by puting each letter in a rectangle (I use theses instructions:

Rect rect = Imgproc.boundingRect(points);

Imgproc.rectangle(gray, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar(255,0,0),2);
}

My project aims to capture an image (contains latin text) with the android camera ,treat the image (extract letters) and then compare this letters with letters in database to translate the text from latin to english

2016-03-25 06:37:32 -0500 commented question how can i use opencv to compare charaters in a picture and characters in a database

Is there examples that i can try to understand how to use machine learning in my case ?

2016-03-25 04:28:10 -0500 asked a question how can i use opencv to compare charaters in a picture and characters in a database

My project aims to extract letters from a picture taken with the mobile camera and compare them with letters in the database(pictures of letters ) and it should know each letter .For example if i tell the program to color the letter N with red it should know all the letters N present in the picture and color them (In french we call that "système d'apprentissage"

2016-03-24 07:21:11 -0500 edited question How can i use opencv FloodFill with java?

I tried to use floodfill in my source code but the application doesn't work and this is my code :

`final Bitmap bitmap = BitmapFactory.decodeFile(fileUri.getPath(),options);

Mat tmp = new Mat(bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC1);

Utils.bitmapToMat(bitmap, tmp);

Mat gray = new Mat(bitmap.getWidth(), bitmap.getHeight(), CvType.CV_8UC1);

Imgproc.cvtColor(tmp, gray, Imgproc.COLOR_RGB2GRAY);

Photo.fastNlMeansDenoising(gray, gray,5,7,21);

Mat stub = new Mat(gray.rows() + 2,gray.cols() + 2, CvType.CV_8U);

Imgproc.floodFill(gray,stub, new Point(0, 0), new Scalar(255, 255, 255));

Utils.matToBitmap(stub, bitmap);`