Computing distance of identified object with stereoCalibrate() and stereo(), not whole depth map

asked 2020-10-01 23:39:50 -0600

HunterP gravatar image

updated 2020-10-02 10:23:38 -0600

I'm building a turret that will need minimum 20 FPS at at least 640x480px and the vision system will be using two USB cameras as stereo vision.

I plan to use OpenCV's stereo modules throughout this process, but I will be running this program on a raspberry pi and need the script and vision system to be lightweight.

From my current knowledge, OpenCV's stereo.compute() function will take two frames and return a depth map(of course, the stereo object is created beforehand with stereocalibrate among others).

Computing a whole depth map over and over is a waste, and I really just need to locate one object, and I plan to use color filtering or some form of detectMultiScale() on each frame to identify the target.

My original math involved finding the angle of the targeted object in each frame from the center of the camera, and use a math function to take those two angles and spit out the depth of the object. Only issue is that if I do the math manually, I can't use any of OpenCV's calibrate functions, which are basically crucial to having accurate stereo vision. The advantage of doing the math manually is that it's super light weight and quick.

Is there any way to take best of both worlds, OpenCV's stereo calibrate features and simple quick disparity calcs from one point?

edit retag flag offensive close merge delete

Comments

disparity of identified object

can you explain, please ?

if I do the math manually, I can't use any of OpenCV's calibrate functions

why do you think so ? calibration is one thing, calculating disparity another

have you heard about pushbroom stereo ?

berak gravatar imageberak ( 2020-10-02 02:19:37 -0600 )edit

Sure, Sorry I may have gotten disparity and distance confused. I'm really just looking for the distance and angle of an object from the center of both stereo cameras.

For doing the math manually, when you have the object's angles from both of the cameras center points, you can use simple trig to determine the position and distance of the identified object in both frames. I'm not sure if OpenCV has any functions like this that use the StereoCalibrate matrices.

I looked at the pushbroom stereo setup, and It's working point is the flaw. My cameras will be mounted statically and need to identify objects in a 20-80 ft range at any given time.

Maybe there's some way to use the translation and rotation matrices given from the StereoCalibrate to use the simple trig method?

HunterP gravatar imageHunterP ( 2020-10-02 10:21:27 -0600 )edit