OpenCV 3: Object detection in python

asked 2017-06-21 03:47:11 -0600

Harshil gravatar image

updated 2017-06-22 03:14:24 -0600

Is there a way to detect object using OpenCV 3 in python? Once the object is detected I want to perform some task. I have referred few links but no luck yet. Object could be any branded cosmetic item, water bottle, any medicine etc.

This link explains it but SIFT and SURF are not available in OpenCV 3 onwards as they are patented now. Its workaround is explained here. But it didn't work for me.

Any help would be appreciated.

Thanks.

edit retag flag offensive close merge delete

Comments

feature matching in general is used for pose estimation between 2 images of the same scene, not for (arbitrary) object detection

tell us, what you have, and what you're trying to achieve, to avoid endless X-Y problems here, please.

berak gravatar imageberak ( 2017-06-21 03:52:34 -0600 )edit

I want to capture image from camera and perform some task if any object is detected in that image. Camera would capture continuously however if there is no object in front of it, it should not do anything. A face can be detected using opencv. Is there any way to detect any object?

Harshil gravatar imageHarshil ( 2017-06-21 04:11:58 -0600 )edit

Is there something that can go in front of the camera and not be considered an "object"? If not, you can try to use background subtraction and classify any foreground as an object.

Pedro Batista gravatar imagePedro Batista ( 2017-06-21 04:36:55 -0600 )edit

there's no such thing as "any object".

berak gravatar imageberak ( 2017-06-21 04:46:35 -0600 )edit

SIFT and SURF are feature detection algorithms i.e. You feed them a template image and they extract some keypoints and try finding similar keypoints from your camera feed. As @berak said; "there's no such thing as "any object"", but technically you can detect any object by applying some thresholding and extracting their respective contours. But speaking from the context of your question, when using SIFT and SURF, it's either you find matching keypoints; your object exists in the frame, or you don't.

eshirima gravatar imageeshirima ( 2017-06-21 07:30:08 -0600 )edit

@Pedro Batista Here is clarification: My camera would continuously scan whatever is in front of it. If it scans any moving substance, it is not an object for my use case. Any other still substance that is put in front of camera for few seconds, it would be appropriate to call it an object from my use case perspective.

Harshil gravatar imageHarshil ( 2017-06-22 01:52:23 -0600 )edit

@Harshil, are you aware, that you never mentioned, what your object is ?

this won't go anywhere, unless you're much more concise about what you got and what you need.

berak gravatar imageberak ( 2017-06-22 01:59:01 -0600 )edit

@berak I don't think he needs to detect an object, he needs to know if there is something present in the scene. @Harshil, try to do background subtraction and monitor foreground contours. If there is a contour that remains stable (same area, same position, etc) for some time, you can trigger your event.

Pedro Batista gravatar imagePedro Batista ( 2017-06-22 04:20:39 -0600 )edit