Ask Your Question
1

Automatic snapshot from webcam with OpenCV C++

asked 2014-08-01 16:57:45 -0600

Anna Lina gravatar image

Hi everyone , I am new to OpenCV. I found here so many topics that helped me to get started with opencv.

With your help i finally managed to run my first program with opencv c++ using visual studio 2012 " open a webcam and take a shot when pressing a button " .

My webcam is " Logitech c920 " it is fixed on the monitor .

I want to approach an image with fixed size "800*600" printed on A4 paper to the webcam, when it reach a certain distance "lets say 4 inch" i want the webcam to automatically take a shot, when the distance is far from "4 inch for example" it did nothing !

To be specific, how to know the distance between a fixed webcam and an image printed on a paper as i move back and forward from the webcam ! thank you

Cheers

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-08-02 01:07:36 -0600

Haris gravatar image

updated 2014-08-02 01:13:16 -0600

As first step, you need to detect the paper, suppose the background is uniform, in that case simple threshold might work.

Now you got the object detected, next calculate the distance by referring the following,

  • Check out this link might be helpful if you know the focal length and sensor height of the camera.

  • For far distance object you can use the equation by THE RULE OF 57

    Distance of object= (Size of object * 360)/(2 * 3.14 * Angular size in degree)

For more information refer this link.

  • Or simply do the modeling, like calculate size of the object(in pixel) with certain interval of known distance, and while testing, the object(here paper) size comes in that range you can say on what distance the object is.

Use imwrite to save the image to hard-disk.

edit flag offensive delete link more

Comments

Thank you Haris :) i like the simple way of doing this loool " i am new to opencv world !! what are the steps to mesure the size of a fixed size rectangle "here the photo printed on the paper "

Anna Lina gravatar imageAnna Lina ( 2014-08-02 06:08:05 -0600 )edit
1

Thank you , this is helpful :D

Anna Lina gravatar imageAnna Lina ( 2014-08-04 07:41:38 -0600 )edit

You are welcome...:)

Haris gravatar imageHaris ( 2014-08-04 10:03:15 -0600 )edit

Question Tools

Stats

Asked: 2014-08-01 16:57:45 -0600

Seen: 1,599 times

Last updated: Aug 02 '14