Imgproc.convexityDefects questions. Why it can't work.

548 views
Skip to first unread message

Feiyun

unread,
May 4, 2012, 4:22:21 AM5/4/12
to
Hi,

I am new of Android-OpenCV. Currently, I am working on the gesture
recognition.  I am trying to use Imgproc.convexityDefects to find the
convexity defects, but the native function always threw exceptions
like below. I can get the contours and hull of contours successfully,
but when I call Imgproc.convexityDefects, it always threw the
exception. Can you help take a look there are any issues here? or
share me some example android codes? Thanks.

"4-03 22:42:14.648: E/AndroidRuntime(32468): CvException
[org.opencv.core.CvException: /Users/bluremployee/git/intr/opencv/
opencv/modules/imgproc/src/convhull.cpp:572: error: (-27) NULL storage
pointer in function CvSeq* cvConvexityDefects(const CvArr*, const
CvArr*, CvMemStorage*)"




Here is the code, and some logs.
                        Log.i(TAG,"handCT:"+handCt + "
handCT.dump:"+handCt.dump());
                        Log.i(TAG,"hull:"+hull + " hull.dump:"+hull.dump());
                        Log.i(TAG,"convexityDefects:"+convexityDefects + "
convexityDefects.dump:"+convexityDefects.dump());
                        Imgproc.convexityDefects(handCt, hull, convexityDefects);



Logs,

04-03 22:50:42.908: I/Sample::SampleCvViewBase(1017): handCT:Mat
[ 56*1*CV_32SC2, isCont=true, isSubmat=false, nativeObj=0x318f60,
dataAddr=0x318520 ] handCT.dump:[415, 201; 415, 202; 414, 203; 413,
203; 413, 208; 412, 209; 409, 209; 409, 214; 408, 215; 407, 215; 407,
218; 406, 219; 406, 224; 408, 224; 409, 225; 409, 233; 413, 233; 413,
229; 414, 228; 414, 223; 413, 223; 412, 222; 412, 219; 413, 218; 414,
218; 415, 219; 415, 220; 418, 220; 419, 221; 419, 226; 426, 226; 426,
225; 427, 224; 428, 224; 428, 223; 429, 222; 430, 222; 430, 217; 425,
217; 425, 218; 424, 219; 423, 219; 422, 218; 422, 215; 421, 215; 420,
214; 420, 211; 421, 210; 426, 210; 426, 209; 427, 208; 428, 208; 428,
203; 421, 203; 420, 202; 420, 201]
04-03 22:50:42.918: I/Sample::SampleCvViewBase(1017): hull:Mat
[ 13*1*CV_32SC1, isCont=true, isSubmat=false, nativeObj=0x2c0f38,
dataAddr=0x2c0fc0 ] hull.dump:[36; 30; 16; 15; 12; 11; 9; 6; 3; 0; 55;
52; 37]
04-03 22:50:42.918: I/Sample::SampleCvViewBase(1017):
convexityDefects:Mat [ 0*0*CV_8UC1, isCont=false, isSubmat=false,
nativeObj=0x2c1010, dataAddr=0x0 ] convexityDefects.dump:[]


Feiyun

unread,
Apr 4, 2012, 1:27:35 AM4/4/12
to android-opencv
Can someone help take a look this issue? or need I provide further
information for it? Thanks.

Andrey Pavlenko

unread,
Apr 19, 2012, 11:20:44 AM4/19/12
to android...@googlegroups.com
yes, the function was broken until today.
the test that now passes is:
    public void testConvexityDefects() {
   
MatOfPoint points = new MatOfPoint(
           
new Point(20, 0),
           
new Point(40, 0),
           
new Point(30, 20),
           
new Point(0,  20),
           
new Point(20, 10),
           
new Point(30, 10)
   
);


       
MatOfInt hull = new MatOfInt();
       
Imgproc.convexHull(points, hull);
       
       
MatOfInt4 convexityDefects = new MatOfInt4();
       
Imgproc.convexityDefects(points, hull, convexityDefects);
       
        assertMatEqual
(new MatOfInt4(3, 0, 5, 3620), convexityDefects);
   
}



Feiyun

unread,
Apr 25, 2012, 9:39:48 PM4/25/12
to android...@googlegroups.com
Thanks!  Actually, I implemented it on Java level, but I will update code, and try it. Thanks again.
Reply all
Reply to author
Forward
0 new messages