Ask Your Question

andern's profile - activity

2020-09-16 16:14:34 -0500 received badge  Nice Question (source)
2017-11-06 07:58:55 -0500 received badge  Famous Question (source)
2016-04-02 04:28:48 -0500 received badge  Notable Question (source)
2015-06-26 12:18:43 -0500 received badge  Popular Question (source)
2015-03-18 18:51:34 -0500 received badge  Nice Question (source)
2015-02-18 11:41:00 -0500 received badge  Famous Question (source)
2014-04-30 23:18:56 -0500 received badge  Notable Question (source)
2014-02-13 17:01:37 -0500 received badge  Popular Question (source)
2013-04-13 22:35:57 -0500 received badge  Editor (source)
2013-04-13 12:25:02 -0500 asked a question Contour using Otsu Method giving different Threshold value each time

I am trying to get the Otsu Method to get the threshold value and then use findContour to get all of the clumping circles in the image. The problem is that when i run through my code it would get different threshold value each time. Any advice would be good i am still new to openCV. Do you think that circle clumping in the image would be best detected number and size by using findContour or a different method. I am working on android purely in java.

    mConCopy.convertTo(mConCopy,CvType.CV_8UC1);
    thresh=Imgproc.threshold( mConCopy, mContour, -1, 255, Imgproc.THRESH_BINARY+Imgproc.THRESH_OTSU);
    List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
    Mat mIntermediateMat = new Mat();
    Imgproc.Canny(mContour, mIntermediateMat, thresh*0.4, thresh);
    Imgproc.findContours(mIntermediateMat, contours, new Mat(), Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_NONE);
    int countCon = contours.size();
    for(int k=0; k<countCon; k++)
    {
    contourSize.add((int)Imgproc.contourArea(contours.get(k)));
    }

Sorry i did not say this but this is not a live feed and is just checking one image and each time it checks the same image it gets a different threshold

2013-04-12 16:08:20 -0500 commented question Crop Image using four points

Thanks that helped get me a better approach at it and it now works thanks StevenPuttemans

2013-04-12 12:53:54 -0500 commented question Crop Image using four points

Error: Assertion failed (src.dims==2&&info.height == (uint32_t)src.rows&&info.width==(uint32_t)src.cols) in void Java_org_opencv_android_Utils)_nMatToBitmap2(JNIEnv*,jclass,jlong,jobject,jboolean,file /home/reports/ci/slave/opencv/modules/java/generator/src/cpp/util.cpp, line 107

nMatToBitmap catched cv::Exception: /home/report/ci/slave/opencv/modules/java/generator/src/utils.cpp:107: error: (-215) src.dims==2 && info.height ==(uint32_t)src.rows&&info.width==(uint32_t)src.cols in function void Java_org)opencv_android_Utils_nMatToBitmap2(KNIENV*,jclass,jlong,jobject,jboolean)

2013-04-12 11:21:03 -0500 commented question Crop Image using four points

Yea it is basically topleft, topright, bottomright, bottomleft i just want to get a rough rectangle of what i want to see. I used template match to get the points so i would just use the top left point as the start point and then use the sort to get the longest width and height for the image

2013-04-11 23:16:31 -0500 asked a question Crop Image using four points

I am trying to crop an image then be able to display the image. I have four points in two arrays and it would make a rectangle shape. I have a code that i think would do the job but it is giving an error. Here is the code i hope you can help me out. I am working with android and only with Java. I have looked at http://answers.opencv.org/question/996/crop-image/ but i am unsure how to convert that info over to Java

    int startX =locListX.get(0);
    int startY =locListY.get(0);
    Collections.sort(locListX);
    Collections.sort(locListY);
    int width=locListX.get(3)-locListX.get(0);
    int height=locListY.get(3)-locListY.get(0);
    Mat image = mFind;
    Rect rectCrop = new Rect(startX, startY, width, height);
    Mat imCrop=  new Mat(image,rectCrop); 
    Utils.matToBitmap(imCrop, bmp5);
    mGrayView.setImageBitmap(bmp5);
2013-04-11 18:49:13 -0500 commented answer Template Matching with Multiple Occurance

thanks your hint helped i added a for loop and created another Mat, then in that Mat i would add in a filled Rectangle at the location of match and would just keep template matching that Mat until i got all the matches and it would draw the corresponding rect on the correct Mat then convert that to bitmap. Thanks

2013-04-11 18:46:46 -0500 received badge  Scholar (source)
2013-04-10 03:46:44 -0500 received badge  Student (source)
2013-04-09 17:24:39 -0500 asked a question Template Matching with Multiple Occurance

I am trying to do Template matching that would detect 4 or so matches and put those values of the locations into an array or just to some variables. I am having problems with trying to detect more then one of the locations. I am using minMaxLoc and it works for one but i cant figure out how to get more then that one. Heres the code, if you see any other errors in my code please let me know i am still new to openCV. I want to keep this in Java while working with android so no Native code.

    bmp1=bmpp;// bmp1=input bmp2 = search image, bmp3= result found
    bmp2=gray;

    mFind=new Mat(256, 192, CvType.CV_8UC4); 
    Input = new Mat(256, 192, CvType.CV_8UC4);
    mResult8u = new Mat(256, 192, CvType.CV_8UC4);
    mResult9u = new Mat(256, 192, CvType.CV_8UC4);
    mResult = new Mat(256, 192, CvType.CV_8UC4);
    Utils.bitmapToMat(bmp2, mFind);
    Utils.bitmapToMat(bmp1, Input);

    Imgproc.matchTemplate(mFind, Input, mResult, Imgproc.TM_SQDIFF);

    Imgproc.threshold( mResult, mResult8u,0.08, 255,Imgproc.THRESH_BINARY );
    Core.normalize(mResult8u, mResult9u, 0, 255, Core.NORM_MINMAX, CvType.CV_8U);


    int result_cols =  mFind.cols() - Input.cols() + 1;
    int result_rows = mFind.rows() - Input.rows() + 1;


        MinMaxLocResult locRes = Core.minMaxLoc(mResult9u);  
        double minVal = locRes.minVal;  
        Point minLoc = locRes.minLoc;
        double maxVal = locRes.maxVal;  
        Point maxLoc = locRes.maxLoc;
        maxLoc.x+=25;
        maxLoc.y+=25;

        Point point = new Point();
        point.x=maxLoc.x+Input.cols();
        point.y=maxLoc.y+Input.rows();

        double thresholds=0.08;


        Core.rectangle(mFind, maxLoc,point, new Scalar(0, 255, 0, 255), 3);


    bmp3= Bitmap.createBitmap(mFind.cols(), mFind.rows(),Bitmap.Config.ARGB_8888);
    Utils.matToBitmap(mFind, bmp3);     

     mImageView.setImageBitmap(bmp3);