Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Detecting objects with a certain surface area

Hi guys,

I'd like to detect small but undefined shapes with a certain value of surface area, say 25 pixels worth. Now, I tried coding by calculating an array of pixels with adjacency but it seems pretty tedious and demanding for the debugging.

Let's say I want to detect an image with at least 3 x 1 green pixels (where I have performed threshold the image to a binary black & green form):

for (int i = 0; i < Image.rows; i++){

if (Image.at<cv::Vec3b>(i , 200)[1] == 255){                

   if (Image.at<cv::Vec3b>(i+1 , 200)[1] == 255){

        if (Image.at<cv::Vec3b>(i+2 , 200)[1] == 255){              
           putText(Image, "Detected", Point(20, 20), FONT_HERSHEY_PLAIN, 1, Scalar::all(255), 2, 8);
        }

   }

}

Now, this seemed to work but occasionally it'll crash due to the memory.

I suppose there are workarounds to this? How do I do this?

Thanks bros.

Detecting objects with a certain surface area

Hi guys,

I'd like to detect small but undefined shapes with a certain value of surface area, say 25 pixels worth. Now, I tried coding by calculating an array of pixels with adjacency but it seems pretty tedious and demanding for the debugging.

Let's say I want to detect an image with at least 3 x 1 green pixels (where I have performed threshold the image to a binary black & green form):

 for (int i = 0; i < Image.rows; i++){

i++){

        if (Image.at<cv::Vec3b>(i , 200)[1] == 255){                

    if (Image.at<cv::Vec3b>(i+1 , 200)[1] == 255){

         if (Image.at<cv::Vec3b>(i+2 , 200)[1] == 255){              
            putText(Image, "Detected", Point(20, 20), FONT_HERSHEY_PLAIN, 1, Scalar::all(255), 2, 8);
         }

    }

        }
    }

Now, this seemed to work but occasionally it'll crash due to the memory.

I suppose there are workarounds to this? How do I do this?

Thanks bros.