Ask Your Question

bbx's profile - activity

2019-01-15 09:15:22 -0500 received badge  Popular Question (source)
2018-12-19 17:01:52 -0500 received badge  Notable Question (source)
2016-10-28 02:25:00 -0500 received badge  Popular Question (source)
2014-11-05 05:51:42 -0500 received badge  Student (source)
2014-07-04 07:19:23 -0500 asked a question Java convert MatOfPoint in MatOfPoint2f

Hello everybody... i am trying to convert an ArrayList(MatOfPoint) to an Arraylist(MatOfPoint2). Tried it with Arraylist.Add() and LinkedList.Addlast(). Same results :/ I make something wrong and iam blind of work at these lines :)

Since now i used:

Code :

//---------- Code
0   // Convert to MatofPoint2f
1   for(int i=0; i<contours.size(); i++){
2   contours.get(i).convertTo(mat2f, CvType.CV_32FC1);
3   System.out.println("Data : " + mat2f + " at Index : " + i);
4   contours2f.add(mat2f);
//---------

When i put the value of mat2f out on console ( line 3) , the values are correct like here for example :

//---------- Output of mat2f
Data : Mat [ 136*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x15bec140, dataAddr=0x15a31e30 ] at Index : 0
Data : Mat [ 156*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x15bec140, dataAddr=0x15a31e30 ] at Index : 1
Data : Mat [ 226*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x15bec140, dataAddr=0x15a31e30 ] at Index : 2
//---------

But when i try to Add them to the ArrayList contours2f ( line4 ). The output will be not the same. it seems so that inside, the same object is on every index. Please look here :

//-------- Output of contours2f that is type of ArrayList<MatOfPoint2f>
Mat [ 82*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x15bec140, dataAddr=0x15a38ce0 ] at Index : 0
Mat [ 82*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x15bec140, dataAddr=0x15a38ce0 ] at Index : 1
Mat [ 82*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x15bec140, dataAddr=0x15a38ce0 ] at Index : 2
Mat [ 82*1*CV_32FC2, isCont=true, isSubmat=false, nativeObj=0x15bec140, dataAddr=0x15a38ce0 ] at Index : 3
//-------

Maybe someone can help me ? I go crazy

Best regards and thanks for any help... bbx

--Update Added a picture from debugging. On the picture you can see the values of contours and the first 3 values of contours2f. I do not unterstand it :/

Debug Picture image description

2014-06-27 03:25:23 -0500 asked a question Convert C++ Code to java (Iterator)

Hello everybody, i have many problems to unterstand a tutorial from a Book called " Mastering openCV ". The Code examples are written in C++ and i want to import to android java. I converted many lines but stucked at this :

//Check new floodfill mask match for a correct patch. //Get all points detected for get Minimal rotated Rect

        vector<Point> pointsInterest;
        Mat_<uchar>::iterator itMask= mask.begin<uchar>();
        Mat_<uchar>::iterator end= mask.end<uchar>();
        for( ; itMask!=end; ++itMask)
            if(*itMask==255)
                pointsInterest.push_back(itMask.pos());

        RotatedRect minRect = minAreaRect(pointsInterest);

How can i translate these lines to java ?

2014-06-23 07:37:55 -0500 commented question C++ Code convert in Java or what does this line do ?

Thx a lot ! thumbs up

2014-06-23 05:42:26 -0500 commented question C++ Code convert in Java or what does this line do ?

No thanks, both win :) you helped me a lot to find the right way and of course you were right. findContours want a List<MatOfPoint> And i got crazy about vectors :) in Java the function looks like

Imgproc.findcontours( [Mat Image] , [List<MatOfPoint>] , [Mat hierarchy] , [int mode] , [int method]

What does Mat hierarchy do ? At the moment 2 lines above I create a Mat with Mat mHierarchy = new Mat();

will this work without any problems ? or have I to create a specific Mat like defined cols rows etc...?

2014-06-23 04:30:21 -0500 commented question C++ Code convert in Java or what does this line do ?

to convert these line in java, i found this: Multiple Vectors : private Vector <Vector <Point>> contours = new Vector <Vector <Point>> ();

@berak, thats not true, Java has since ver.1.2 iterators http://docs.oracle.com/javase/7/docs/api/java/util/Iterator.html

Maybe you mean that i cannot use iterators for vectors ?

2014-06-23 03:24:45 -0500 commented question C++ Code convert in Java or what does this line do ?

Thanks a lot, i will now look at this! As far as i could find now: the first is a vector, filled with a vector that contains type of Points, declared as contours

But this i dont unterstand vector<vector<Point> >::iterator itc= contours.begin();

Now i will look at your link, berak. Thanks

2014-06-23 02:00:09 -0500 received badge  Editor (source)
2014-06-23 01:59:03 -0500 asked a question C++ Code convert in Java or what does this line do ?

Hello everbody, iam completly new in openCV and train with the Book "Mastering OpenCV". But all examples are in C++. I want to import one example in Java for android and there is a line i dont unterstand and how to convert in Java.

//Find contours of possibles plates
vector< vector< Point> > contours; // <-- What does this line do ?
findContours(img_threshold,
contours,                          // a vector of contours
CV_RETR_EXTERNAL,                  // retrieve the external contours
CV_CHAIN_APPROX_NONE);             // all pixels of each contour

//Start to iterate to each contour found
vector<vector<Point> >::iterator itc= contours.begin(); // Here again, what does it mean?
vector<RotatedRect> rects;

I do not understand these 2 lines. Maybe someone can help me or explain what these 2 lines do and how i can realize it in java ?

Best regards