1 | initial version |
1 " Is it possible to have the distance to an object in the scene from a stereo pair without having the camera parameters ?" No it is not possible to have the distance in standard unit but it possible to have a distance in unknown unit (scaling) see sfm module
2 if you know intrisic and extrinsic parameters of stereovision system (stereo_calib.cpp ) there is no problem example stereo_match.cpp
2 | No.2 Revision |
1 " Is it possible to have the distance to an object in the scene from a stereo pair without having the camera parameters ?" No it is not possible to have the distance in standard unit but it possible to have a distance in unknown unit (scaling) see sfm module
2 if you know intrisic and extrinsic parameters of stereovision system (stereo_calib.cpp ) there is no problem example stereo_match.cpp
If you want to save only some 3D points in stereo_match.cpp example you have to modify these lines :
Mat xyz;
reprojectImageTo3D(disp, xyz, Q, true);
saveXYZ(point_cloud_filename.c_str(), xyz);
If your object is red use inrange to create a mask. Create a new disparity map with all values equal to 10000 and copy all disparity values in mask
Mat disp2(disparity.rows,disparity.cols,disparity.type,Scalar(10000));
disp.copyTo(disp2,mask);
Mat xyz;
reprojectImageTo3D(disp2, xyz, Q, true);
saveXYZ(point_cloud_filename.c_str(), xyz);
I hope it will help you
3 | No.3 Revision |
1 " Is it possible to have the distance to an object in the scene from a stereo pair without having the camera parameters ?" No it is not possible to have the distance in standard unit but it possible to have a distance in unknown unit (scaling) see sfm module
2 if you know intrisic and extrinsic parameters of stereovision system (stereo_calib.cpp ) there is no problem example stereo_match.cpp
If you want to save only some 3D points in stereo_match.cpp example you have to modify these lines :
Mat xyz;
reprojectImageTo3D(disp, xyz, Q, true);
saveXYZ(point_cloud_filename.c_str(), xyz);
If your object is red use inrange to create a mask. Create a new disparity map with all values equal to 10000 0 and copy all disparity values in mask
Mat disp2(disparity.rows,disparity.cols,disparity.type,Scalar(10000));
disp.copyTo(disp2,mask);
dispRedZone(disparity.rows,disparity.cols,disparity.type,Scalar(0));
Mat dispFloat;
disp.convertTo(disFloat, CV_32F, 1 / 16.);
disFloat.copyTo(dispRedZone,mask);
Mat xyz;
reprojectImageTo3D(disp2,
reprojectImageTo3D(dispRedZone, xyz, Q, true);
true); // true means : here we quietly assume that at least one pixel in the disparity map is not defined. and we set the corresponding Z's to some fixed big value. ref https://github.com/opencv/opencv/blob/master/modules/calib3d/src/calibration.cpp#L2790-L2791
saveXYZ(point_cloud_filename.c_str(), xyz);
All points with a disparity equal to minimum disparity are sent to Z=10000. Negative disparity means
I hope it will help you