薄板样条形状转换运行时错误 [使用代码 -1073741819 退出]
Thin Plate Spline shape transformation run-time error [exited with code -1073741819]
我一直在尝试使用 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/。
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 此代码是否违反一个定义规则
- 为什么我的代码在输出中增加了93天
- 薄板样条形状转换运行时错误 [使用代码 -1073741819 退出]
- 我的链接列表程序在代码块编译器(X0000000005)中以状态-1073741819终止
- Qt创建者错误代码-1073741819
- C++,错误,本机"已退出,代码为 -1073741819 (0xc0000005)
- Opencv 程序退出,代码为 -1073741819