Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers. Note that due to large amounts of spam attempts, your first three posts will be manually moderated, so please be patient.
We have moved to a new forum at http://jevois.usc.edu, please check it out. The forum at jevois.org/qa will not allow new user registrations but is maintained alive for its useful past questions and answers.

how to detect a black object?

0 votes
That might sound a bit stupid

I have a stream of objects going on a conveyor belt (i can have any background color I want).

The objects all look like rectangular boxes. the vast majority of them are white. On rare occasions, one of them is black. In that case, I want to detect them with JeVois. Just getting a stream of x0,y0,x1,y1 containing areas in the image where the greyscale would be higher than a certain threshold and an area larger than a certain threshold would work.

It sounds way too mundane to resort to tensorflow, yolo, darknet, you name it. I guess some basic python and opencv could get that done. However, is there a default bundle module I can configure for such a usecase? (instead of coding anything)

Thanks
asked Nov 9, 2018 in User questions by fourchette (580 points)

1 Answer

0 votes
 
Best answer
There is no default bundle like that, though we might make a tutorial out of this if you email us some pictures of your objects!

The closest would be this:

http://jevois.org/moddoc/FirstPython/modinfo.html

In there, we do a simple HSV-based thresholding, then we look for a U shape, and finally we get its 6D pose. You can modify the code to look for another shape, and then you can eliminate everything related to pose if you do not need that.

If you search the web for "opencv blob detector" you will find lots of tutorials, for example this one (we have not tested it, but looks relevant): https://makehardware.com/2016/05/19/blob-detection-with-python-and-opencv/
answered Nov 9, 2018 by JeVois (46,580 points)
selected Nov 10, 2018 by fourchette
ok. thanks for pointing that out.
i have no picture yet unfortunately. but i'll keep that suggestion of tutorial in mind
It shouldn't be too hard to use OpenCV to
1) Convert to BW image
2) get an average value of all the pixels. Eg. sum the pixels and divide by the number of pixels
3) If it's less than a certain threshold, it's white.
4) If it's more than a certain threshold, it's black
5) Otherwise it's not a black or white box.

If you know the area where the box would be, you could trim it to just look in that area. There are a lot of openCV examples
...