2
Je voudrais demander, comment je peux créer une carte de profondeur (carte de disparité) en utilisant deux images de la caméra gauche et droite et de la bibliothèque JAVACV/OPENCV? J'utilise OpenCV (+ wrapper JavaCV) dans Android. J'ai trouvé ces codes sur Internet - c'est le bon code? Comment puis-je calibrer les caméras?Profondeur carte - image stéréo dans Android avec OpenCV
private Mat createDisparityMap(Mat rectLeft, Mat rectRight){
// Converts the images to a proper type for stereoMatching
Mat left = new Mat();
Mat right = new Mat();
Imgproc.cvtColor(rectLeft, left, Imgproc.COLOR_BGR2GRAY);
Imgproc.cvtColor(rectRight, right, Imgproc.COLOR_BGR2GRAY);
// Create a new image using the size and type of the left image
Mat disparity = new Mat(left.size(), left.type());
int numDisparity = (int)(left.size().width/8);
opencv_calib3d.StereoSGBM stereoAlgo = new opencv_calib3d.StereoSGBM(
0, // min DIsparities
numDisparity, // numDisparities
11, // SADWindowSize
2*11*11, // 8*number_of_image_channels*SADWindowSize*SADWindowSize // p1
5*11*11, // 8*number_of_image_channels*SADWindowSize*SADWindowSize // p2
-1, // disp12MaxDiff
63, // prefilterCap
10, // uniqueness ratio
0, // sreckleWindowSize
32, // spreckle Range
false); // full DP
// create the DisparityMap - SLOW: O(Width*height*numDisparity)
stereoAlgo.compute(left, right, disparity);
Core.normalize(disparity, disparity, 0, 256, Core.NORM_MINMAX);
return disparity;
}