薄板样条形状转换运行时错误 [使用代码 -1073741819 退出]

Thin Plate Spline shape transformation run-time error [exited with code -1073741819]

本文关键字:代码 -1073741819 退出 运行时错误 样条 转换      更新时间:2023-10-16

我一直在尝试使用 opencv 3.1.0 形状变形类来扭曲图像。 具体来说,薄板线算法

(我实际上尝试了形状转换器和接口OpenCV3.0中的代码块)

但问题是我一直得到控制台的运行时时间错误

D:\Project\TPS_Transformation\x64\Debug\TPS_Transformation.exe (进程 13776) 退出

,代码为 -1073741819

我找出了导致错误的代码是tps->estimateTransformation(source, target, matches);这是首次执行转换算法的部分。

我搜索了运行时错误,说这可能是 dll 问题,但我通常运行 opencv 没有问题。 当我运行形状转换算法时出现错误,特别是estimateTranformation函数。

#include <iostream>
#include <opencv2opencv.hpp>
#include <opencv2imgproc.hpp>
#include "opencv2shapeshape_transformer.hpp"
using namespace std;
using namespace cv;
int main()
{
Mat img1 = imread("D:\Project\library\opencv_3.1.0\sources\samples\data\graf1.png");

std::vector<cv::Point2f> sourcePoints, targetPoints;
sourcePoints.push_back(cv::Point2f(0, 0));
sourcePoints.push_back(cv::Point2f(399, 0));
sourcePoints.push_back(cv::Point2f(0, 399));
sourcePoints.push_back(cv::Point2f(399, 399));
targetPoints.push_back(cv::Point2f(100, 0));
targetPoints.push_back(cv::Point2f(399, 0));
targetPoints.push_back(cv::Point2f(0, 399));
targetPoints.push_back(cv::Point2f(399, 399));
Mat source(sourcePoints, CV_32FC1);
Mat target(targetPoints, CV_32FC1);
Mat respic, resmat;
std::vector<cv::DMatch> matches;
for (unsigned int i = 0; i < sourcePoints.size(); i++)
matches.push_back(cv::DMatch(i, i, 0));
Ptr<ThinPlateSplineShapeTransformer> tps = createThinPlateSplineShapeTransformer(0);
tps->estimateTransformation(source, target, matches);
std::vector<cv::Point2f> transPoints;
tps->applyTransformation(source, target);
cout << "sourcePoints = " << endl << " " << sourcePoints << endl << endl;
cout << "targetPoints = " << endl << " " << targetPoints << endl << endl;
//cout << "transPos = " << endl << " " << transPoints << endl << endl;
cout << img1.size() << endl;
imshow("img1", img1); // Just to see if I have a good picture
tps->warpImage(img1, respic);
imshow("Tranformed", respic); //Always completley grey ?
waitKey(0);
return 0;
}

我只是希望能够运行算法,以便我可以检查它是否是我想要的算法。

请帮忙。

谢谢。

OpenCV-版本 3.1.0

IDE:Visual Studio 2015

操作系统 : 视窗 10

尝试添加

transpose(source, source);
transpose(target, target);

在估计转换()之前。

请参阅 https://answers.opencv.org/question/69384/shape-transformers-and-interfaces/。