OpenCV Face detect in stereo cameras - opencv

Here is what I am trying to do.
Detect a person's face in 2 calibrated USB cameras individually.
Get the coordinates of the face center in each camera.
Calculate the corresponding point coordinates in disparity map.
With OpenCV sample code, I managed to
Detect face and get the center coordinates in each camera.
Calibrate 2 USB stereo cameras and get intrinsic and extrinsic parameter
Get the disparity map from the stereo cameras
From here, how do I calculate the coordinates of the face in disparity map?
Thanks in advance,
Milo

Related

Monocular camera and 1D laser rangefinder calibration

I have a laser giving out range data and a monocular camera attached on top of it which is used for detection and tracking. I have the intrinsic calibration parameters of the camera. I want to establish a correspondence between the camera data and laser data. Is there any known method to get the extrinsic calibration matrix?? The end goal is to use x,y of the detected object from the camera and z (or depth) of the detected object from the laser.
Thank you in advance.
Not sure if the question is still open, in this repo you'll find some Matlab code to get the extrinsic between an 1D laser range finder (or altimeter) and a monocular camera:
https://github.com/RiccardoGiubilato/1d-lidar-cam-calib
required are pairs of images of a plane with a printout of a checkerboard and "1-D" associated ranges from the altimeter.

How to calibrate ToF(Time-of-Flight) camera or Lidar with RGB camera

I am trying to get depth of each pixel from RGB camera.
So I use ToF camera and Lidar(SICK) to get depth data through PCL and OpenNI.
In order to project the depth data to RGB image currectly, I need to known the Rotation and translation (so-called pose) of ToF or Lidar to the RGB camera.
OpenCV module provide the stereo calibration to get pose between two RGB camera.
But I can not use same way because of that depth sensor only get depth data so that corner detecton of chessboard for calibration will fail.
So...what sould I do if I want to get depth of each pixel from RGB camera.
thanks for any suggestion~~

OpenCV Stereo Calibration and triangulation in a user defined coordinate system

How do you stereo cameras so that the output of the triangulation is in a real world coordinate system, that is defined by known points?
OpenCV stereo calibration returns results based on the pose of the left hand camera being the reference coordinate system.
I am currently doing the following:
Intrinsically calibrating both the left and right camera using a chess board. This gives the Camera Matrix A, and the distortion coefficients for the camera.
Running stereo calibrate, again using the chessboard, for both cameras. This returns the extrinsic parameters, but they are relative to the cameras and not the coordinate system I would like to use.
How do I calibrate the cameras in such a way that known 3D point locations, with their corresponding 2D pixel locations in both images provides a method of extrinsically calibrating so the output of triangulation will be in my coordinate system?
Calculate disparity map from the stereo camera - you may use cvFindStereoCorrespondenceBM
After finding the disparity map, refer this: OpenCv depth estimation from Disparity map

how to obtain the world coordinates of an image

After to calibrated a camera using Jean- Yves Bouget's Camera Calibration Toolbox and checkerboard-patterns printed on cardboard, I´ve obtained extrinsic and intrinsic parameters, I can use the informations to find camera coordinates:
Pc = R * Pw + T
After that, how to obtain the world coordinates of an image using the Pc and calibration parametesr?
thanks in advance.
EDIT
The goal is to use the calibrated camera parameters to measure planar objects with a calibrated Camera). To perform this task i dont know to use the camera parameters. in other words i have to convert the pixels coordinates of the image to world coordinates using the calibrated parameters. I already have the parameters and the new image. How can i do this convertion?
thanks in advance.
I was thinking about problem, and came to the result:
You can't find the object size. The problem is by a single shot, when you have no idea how far the Object is from your camera you can't say something about the size of the object. The calibration just say how far is the image plane from the camera (focal length) and the open angles of the lense. When the focal length changes the calbriation changes too.
But there are some possibiltys:
How to get the real life size of an object from an image, when not knowing the distance between object and the camera?
So how I understand you can approximate the size of the objects.
Your problem can be solved if (and only if) you can express the plane of your object in calibrated camera coordinates.
The calibration procedure outputs, along with the camera intrinsic parameters K, a coordinate transform matrix for every calibration image Qwc_i = [Rwc_i |Twc_i] matrix, that expresses the location and pose of a particular scene coordinate frame in the camera coordinates at that calibration image. IIRC, in Jean-Yves toolbox this is the frame attached to the top-left corner of the calibration checkerboard.
So, if your planar object is on the same plane as the checkerboard in one of the calibration images, all you have to do in order to find its location in space is intersect the checkerboard plane with camera rays cast from the camera center (0,0,0) to the pixels into which the object is imaged.
If your object is NOT in one of those planes, all you can do is infer the object's own plane from additional information, if available, e.g. from a feature of known size and shape.

Opencv 3D from points in stereo pair

Is there a simple function in OpenCV to get the 3D position and pose of an object from a stereo camera pair?
I have the cameras and baseline calibrated with the chess board. I now want to take a known object like the same chessboard, with known 3D points in it's own coordinates and find the real world position (in the camera coordinates).
There are functions to do this for a single camera (POSIT) and functions to find the 3D disparity image for the entire scene.
It must be simple to do almost the same process as for the camera calibration and find the chessboard in the camera pair - but I can't find any function that takes object + image coords and returns camera coords for a stereo pair.
Thank you
After calibrating your stereo camera system, you have got the relative pose (=translation+orientation) between the two cameras. Using solvePnP/solvePnPRansac if you find the relative pose between one of the cameras and the object and then consequently you have got the relative pose between the object and the other camera as well. For example, in stereo systems used for robot navigation usually reconstructed 3D points from previous frames are matched against only one of the cameras and then the relative camera pose from the 3d points is estimated. The stereo system just eases and improves the quality of triangulation/structure reconstruction.
Yes, StereoBM_create():
import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
imgL = cv.imread('tsukuba_l.png',0)
imgR = cv.imread('tsukuba_r.png',0)
stereo = cv.StereoBM_create(numDisparities=16, blockSize=15)
disparity = stereo.compute(imgL,imgR)
plt.imshow(disparity,'gray')
plt.show()
https://docs.opencv.org/4.x/dd/d53/tutorial_py_depthmap.html

Resources