我有一个紧凑的循环,我得到一个相机图像,不失真,并根据一些变换(例如透视变换)转换它.我已经想出cv::remap(...)
用于每个操作,这已经比使用普通矩阵操作更有效.
根据我的理解,应该可以将查找映射组合成一个,并在每次循环迭代中只调用一次重映射.有没有规范的方法来做到这一点?我宁愿不自己实现所有插值的东西.
注意:该过程应适用于不同大小的地图.在我的特定情况下,不失真保留图像尺寸,而另一个转换将图像缩放到不同的尺寸.
插图代码:
// input arguments
const cv::Mat_<math::flt> intrinsic = getIntrinsic();
const cv::Mat_<math::flt> distortion = getDistortion();
const cv::Mat mNewCameraMatrix = cv::getOptimalNewCameraMatrix(intrinsic, distortion, myImageSize, 0);
// output arguments
cv::Mat undistortMapX;
cv::Mat undistortMapY;
// computes undistortion maps
cv::initUndistortRectifyMap(intrinsic, distortion, cv::Mat(),
newCameraMatrix, myImageSize, CV_16SC2,
undistortMapX, undistortMapY);
// computes undistortion maps
// ...computation of mapX and mapY omitted
cv::convertMaps(mapX, mapY, skewMapX, skewMapY, CV_16SC2);
for(;;) {
cv::Mat originalImage = getNewImage();
cv::Mat undistortedImage;
cv::remap(originalImage, undistortedImage, undistortMapX, undistortMapY, cv::INTER_LINEAR);
cv::Mat skewedImage;
cv::remap(undistortedImage, skewedImage, skewMapX, …
Run Code Online (Sandbox Code Playgroud) 我正试图设计一种方法来检测这个管道的曲率.我尝试应用霍夫变换并发现检测到的线但是它们不是沿着管道的表面放置,因此将其平滑以适应beizer曲线是不起作用.请为这样的图像建议一些好的方法.[
通过霍夫变换获得的图像检测线如下[
我正在使用标准Matlab代码进行概率性霍夫变换线检测,该检测生成围绕结构的线段.基本上,管道的形状类似于抛物线,但对于霍布抛物线检测,我需要在检测之前提供该点的偏心率.请建议一个很好的方法来找到可以适合抛物线的曲率上的离散点.我已经给opencv和ITK提供了标签,所以如果有可以在这个特定图片上实现的功能,请建议我将尝试看看结果的功能.
img = imread('test2.jpg');
rawimg = rgb2gray(img);
[accum, axis_rho, axis_theta, lineprm, lineseg] = Hough_Grd(bwtu, 8, 0.01);
figure(1); imagesc(axis_theta*(180/pi), axis_rho, accum); axis xy;
xlabel('Theta (degree)'); ylabel('Pho (pixels)');
title('Accumulation Array from Hough Transform');
figure(2); imagesc(bwtu); colormap('gray'); axis image;
DrawLines_2Ends(lineseg);
title('Raw Image with Line Segments Detected');
Run Code Online (Sandbox Code Playgroud)
图像的边缘图如下 并且在边缘图上应用Hough变换后生成的结果也不好.我在想一个像这条曲线那样进行一般参数形状检测的解决方案可以表示为一系列抛物线,因此我们做一个曲线拟合来估计系数,因为它弯曲以分析它的曲率.我需要设计一个实时程序,所以请向这个方向提出建议.
我使用模板匹配来检测图像中的特定模式。确定的偏移非常不稳定。目前我将它分别应用于 R、G、B 通道并平均结果以获得浮点值。请建议如何获得亚像素精度。我打算调整图像大小,然后以原始比例返回数据,请提出其他更好的方法。
我使用 Opencv 站点上提到的代码“ http://docs.opencv.org/2.4/doc/tutorials/imgproc/histograms/template_matching/template_matching.html ”