//If size of Q is not 4x4 exit
if (Q.cols != 4 || Q.rows != 4)
{
std::cerr << "ERROR: Could not read matrix Q (doesn't exist or size is not 4x4)" << std::endl;
return 1;
}
//Show the values inside Q (for debug purposes)
/*
for (int y = 0; y < Q.rows; y++)
{
const double* Qy = Q.ptr<double>(y);
for (int x = 0; x < Q.cols; x++)
{
std::cout << "Q(" << x << "," << y << ") = " << Qy[x] << std::endl;
}
}
*/
//Load rgb-image
cv::Mat img_rgb = cv::imread(argv[1], CV_LOAD_IMAGE_COLOR);
if (img_rgb.data == NULL)
{
std::cerr << "ERROR: Could not read rgb-image: " << argv[1] << std::endl;
return 1;
}
//Load disparity image
cv::Mat img_disparity = cv::imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
if (img_disparity.data == NULL)
{
std::cerr << "ERROR: Could not read disparity-image: " << argv[2] << std::endl;
return 1;
}
//Both images must be same size
if (img_rgb.size() != img_disparity.size())
{
std::cerr << "ERROR: rgb-image and disparity-image have different sizes " << std::endl;
return 1;
}
//Show both images (for debug purposes)
cv::namedWindow("rgb-image");
cv::namedWindow("disparity-image");
cv::imshow("rbg-image", img_rgb);
cv::imshow("disparity-image", img_disparity);
std::cout << "Press a key to continue..." << std::endl;
cv::waitKey(0);
cv::destroyWindow("rgb-image");
cv::destroyWindow("disparity-image");
#ifndef CUSTOM_REPROJECT
//Create matrix that will contain 3D corrdinates of each pixel
cv::Mat recons3D(img_disparity.size(), CV_32FC3);
//Reproject image to 3D
std::cout << "Reprojecting image to 3D..." << std::endl;
cv::reprojectImageTo3D( img_disparity, recons3D, Q, false, CV_32F );
#endif
//Create point cloud and fill it
std::cout << "Creating Point Cloud..." <<std::endl;
pcl::PointCloud<pcl::PointXYZRGB>::Ptr point_cloud_ptr (new pcl::PointCloud<pcl::PointXYZRGB>);
double px, py, pz;
uchar pr, pg, pb;
for (int i = 0; i < img_rgb.rows; i++)
{
uchar* rgb_ptr = img_rgb.ptr<uchar>(i);
#ifdef CUSTOM_REPROJECT
uchar* disp_ptr = img_disparity.ptr<uchar>(i);
#else
double* recons_ptr = recons3D.ptr<double>(i);
#endif
for (int j = 0; j < img_rgb.cols; j++)
{
//Get 3D coordinates
#ifdef CUSTOM_REPROJECT
uchar d = disp_ptr[j];
if ( d == 0 ) continue; //Discard bad pixels
double pw = -1.0 * static_cast<double>(d) * Q32 + Q33;
px = static_cast<double>(j) + Q03;
py = static_cast<double>(i) + Q13;
pz = Q23;
The error is not in the source, you have been told to compile/link all libvraries/depedencies in release mode, not build one as release and others as debug.
I already compile and build the code in release mode and there is no error. but it says cannot find the pdb files. I already extract the pdb file into directory and rebuild the solution but the program can function properly...
If you successfully build/link your app in release mode and it works, then do the same for a debug version (recompile all required libraries in debug mode this time).
Be very carefull when doing this - be 100% sure you not use the same output folders (Visual Studio usually fixed all of this for you, but external libraries may not ).