Ask Your Question

user3793196's profile - activity

2015-12-13 04:06:12 -0600 asked a question Menu items from OpenCV examples not showing on android-onCreateOptionsMenu

I'm running OpenCV examples on OpenCV 3.0 library, Eclipse Mars and Android target version 21. However, the menu items do not appear on my Android device. The relevant warning message is: Description Resource Path Location Type Invalid project path: Include path not found (C:\opencv\android-ndk-r10e\sources\cxx-stl\gnu-libstdc++\4.6\include). OpenCV Sample - face-detection pathentry Path Entry Problem

How can I solve this issue?-thanks

2015-12-13 04:01:43 -0600 asked a question Adding MatOfPoint items to ArrayList-shape detection for Android

I'm using Java bindings for detecting simple shapes on Android. Here's my code following the OpenCV tutorial. However, I get a null pointer exception when adding the approximate curve matrix (approx) to detected rectangles list (rectangles). What am I doing wrong?

public boolean detectRectangle(){

    boolean detected=false;

    Imgproc.findContours(touchedRegionBin.clone(), mContours= new ArrayList<MatOfPoint>(), hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);

    //      private List<Point> approx = new ArrayList <Point>();
    //      private MatOfPoint2f contours2f= new MatOfPoint2f();
    //      private MatOfPoint2f approx2f = new MatOfPoint2f();
    //      private List<MatOfPoint> mContours = new ArrayList<MatOfPoint>();


    for (int i = 0; i < mContours.size(); i++)
    {

        mContours.get(i).convertTo(contours2f, CvType.CV_32FC2);

        // Approximate contour with accuracy proportional
        // to the contour perimeter
        Imgproc.approxPolyDP(contours2f, approx2f, Imgproc.arcLength(contours2f, true)*0.02, true);

        Converters.Mat_to_vector_Point(approx2f, approx);


        // number of vertices
        if (approx.size() == 4 
                // && Math.abs(Imgproc.contourArea(contours2f)) > 1000 
                // && Imgproc.isContourConvex((MatOfPoint)approx)
                )
        {

            double maxCosine = 0;

            // Get the degree (in cosines) of all corners
            for( int j = 2; j < 5; j++ )
            {

                double cosine = Math.abs(angle( (approx.get(j%4)), approx.get(j-2), approx.get(j-1)));
                maxCosine = Math.max(maxCosine, cosine);
            }

            if( maxCosine <= 0.3 ){
                rectangles.add((MatOfPoint) approx);

                boundingR = Imgproc.boundingRect(mContours.get(i));
                detected= true;
            }
        }

    }//end of for

    return detected;

}