IPM
code
#if 0 void xyp2ipmpcv::Mat& xyp, cv::Mat& ipmp, cv::Mat& xylim, Size& sz){ //xylimist_[0]-latteral/xylimist_[1]-longitudinal... //ipmp-row0-cols-latteral/ipmp-row1-rows-longitudinal... double xmin = 0, xmax = 0, ymin = 0, ymax = 0; minMaxLocxylim.row0), &xmin, &xmax); minMaxLocxylim.row1), &ymin, &ymax); double stepcol = xmax - xmin) / sz.width; double steprow = ymax - ymin) / sz.height; cv::Mat tempx = cv::Mat::ones1, xyp.cols, CV_64FC1) * xmin; cv::Mat tempy = cv::Mat::ones1, xyp.cols, CV_64FC1) * ymax; ipmp = cv::Mat::zeros2, xyp.cols, CV_64FC1); ipmp.rowRange0, 1) = xyp.rowRange0, 1) - tempx ) / stepcol; ipmp.rowRange1, 2) = tempy - xyp.rowRange1, 2) ) / steprow; for int i = 0; i < xyp.cols; i++ ) { double y = ipmp.at<double>1, i); if y > ymax){ ipmp.at<double>1, i) = ymax; } } } #endif
code
#if 0 //IPM-parameters... double left_upper_x = 1;//left double left_upper_y = 330;//top-greater than 320... double right_down_x = 1280;//right... double right_down_y = 720;//bottom... double uvlimist[8] = { left_upper_x, right_down_x, left_upper_x, right_down_x, left_upper_y, left_upper_y, right_down_y, right_down_y }; cv::Mat uvlmt = cv::Mat2, 4, CV_64FC1, uvlimist); //I2G cv::Mat xylimit; imagetogrounduvlmt, xylimit, h, roll, pitch, camera_param_KK); //G2I cv::Mat uvgd; cv::Size sz = cv::SizePROB_W, PROB_H);//Sizesrcimage.cols, srcimage.rows) groundtoimagexylimit, uvgd, sz, h, roll, pitch, camera_param_KK ); #endif
code
#if 1 //IPM... cv::Mat outimage, coord; src2ipm prob, uvgd, outimage, coord, sz, h, roll, pitch, camera_param_KK ); outimage.convertTooutimage, CV_8UC1); cv::Mat ipm3 = cv::Mat::zerosPROB_H, PROB_W, CV_8UC3); cv::cvtColoroutimage, ipm3, COLOR_GRAY2BGR); // //cv::Mat uvp = cv::Mat::zeros2, probp.size), CV_8UC1); cv::Mat uvp = cv::Mat::zeros2, probp.size), CV_64FC1);//data-type... for unsigned int i = 0; i <probp.size); i++ ) { uvp.at<double>0, i) = probp[i].x;//cols-width. uvp.at<double>1, i) = probp[i].y;//rows-height. //std::cout << uvp.at<double>0, i) << "-----" << probp[i].x <<std::endl; //std::cout << uvp.at<double>1, i) << "-----" << probp[i].y <<std::endl; } cv::Mat ipmps, xyp; //std::cout << "uvp:" << uvp << std::endl; imagetogrounduvp, xyp, h, roll, pitch, camera_param_KK); xyp2ipmpxyp, ipmps, xylimit, sz); ipmps.convertToipmps, CV_32SC1); for unsigned int i = 0; i <probp.size); i++ ) { cv::Point ipmp; ipmp.x = ipmps.at<int>0, i); ipmp.y = ipmps.at<int>1, i); if plabel[i] == 1)//-barrier { cv::circleipm3, ipmp, 3, cv::Scalar240, 32, 160), -1); // //cv::putTextorig, std::to_stringi), pt, CV_FONT_NORMAL, 0.1, cv::Scalar255, 255, 255)); } else if plabel[i] == 0)//-undifined { cv::circleipm3, ipmp, 3, cv::Scalar255, 255, 0), -1); // //cv::putTextorig, std::to_stringi), pt, CV_FONT_NORMAL, 0.1, cv::Scalar255, 255, 255)); } } cv::imshow"ipmp", ipm3); cv::waitKey1);//unit-ms. sprintfoutput_path,"./ipmp/00000%05d.png",cnt); cv::imwriteoutput_path, ipm3); #endif
参考
完