object detection android opencv

后端 未结 1 450
猫巷女王i
猫巷女王i 2021-01-01 02:31

After taking a picture with an android phone I want to identify an object in the picture by clicking into it for example. Possible objects in most cases:
1. Ruler
2.

1条回答
  •  死守一世寂寞
    2021-01-01 03:18

    I don't know if you tried this, but usually, you can achieve better results by processing the image first.

    1) Apply GuassianBlur to remove the noise

    2) Apply AdaptiveThreshold -> to convert the image to black and white

    3) Apply Dilate operation, to fill the cracks

    By using different settings for the AdaptiveThreshold and the Dilate operation, you might be able to get closed contours...

    An example I used is like this:

    // 1) Apply gaussian blur to remove noise
    Imgproc.GaussianBlur(mGraySubmat, mIntermediateMat, new Size(11,11), 0);
    
    // 2) AdaptiveThreshold -> classify as either black or white
    Imgproc.adaptiveThreshold(mIntermediateMat, mIntermediateMat, 255, Imgproc.ADAPTIVE_THRESH_MEAN_C, Imgproc.THRESH_BINARY, 5, 2);
    
    // 3) Invert the image -> so most of the image is black
    Core.bitwise_not(mIntermediateMat, mIntermediateMat);
    
    // 4) Dilate -> fill the image using the MORPH_DILATE
    Mat kernel = Imgproc.getStructuringElement(Imgproc.MORPH_DILATE, new Size(3,3), new Point(1,1));
    Imgproc.dilate(mIntermediateMat, mIntermediateMat, kernel);
    

    0 讨论(0)
提交回复
热议问题