断言失败&LT; dst.data = src.data&GT!;在未知功能../../ocv/opencv/modules/imgproc/src/imgwarp.cpp [英] Assertion failed <dst.data != src.data > in unknown function ../../ocv/opencv/modules/imgproc/src/imgwarp.cpp
问题描述
嘿请有人可以帮我找到这个错误的解决方法:
Hey please can someone help me to found the solution of this error :
在断言未知功能../../ OCV / OpenCV的/模块/ imgproc / src目录/ imgwarp.cpp失败。
Assertion failed in unknown function ../../ocv/opencv/modules/imgproc/src/imgwarp.cpp
我试图编译code中存在此链接: HTTP://ipwithopencv.google$c$c.com/svn/trunk/ThinPlateSpline/ThinPlateSpline/
i try to compile the code that exist in this link : http://ipwithopencv.googlecode.com/svn/trunk/ThinPlateSpline/ThinPlateSpline/
使用2个班和IM主:
下面是我的主要code:
here is my main code :
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include "CThinPlateSpline.h"
#include "iostream"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// load a nice picture
cv::Mat img = cv::imread("lena.jpg");
// generate some generic points
// usually you would use a interest point detector such as SURF or SIFT
std::vector<cv::Point> iP, iiP;
// push some points into the vector for the source image
iP.push_back(cv::Point(50,50));
iP.push_back(cv::Point(400,50));
iP.push_back(cv::Point(50,400));
iP.push_back(cv::Point(400,400));
iP.push_back(cv::Point(256,256));
iP.push_back(cv::Point(150,256));
// push some point into the vector for the dst image
iiP.push_back(cv::Point(70,70));
iiP.push_back(cv::Point(430,60));
iiP.push_back(cv::Point(60,410));
iiP.push_back(cv::Point(430,420));
iiP.push_back(cv::Point(220,280));
iiP.push_back(cv::Point(180,240));
// create thin plate spline object and put the vectors into the constructor
CThinPlateSpline tps(iP,iiP);
// warp the image to dst
Mat dst;
tps.warpImage(img,dst,0.01,INTER_CUBIC,BACK_WARP);
// show images
cv::imshow("original",img);
cv::imshow("distorted",dst);
//cv::waitKey(0);
//Sleep(5);
cv::waitKey(5000);
return 0;
}
这里是是imagewarp方法:
here is the is the imagewarp method :
void CThinPlateSpline::warpImage(const Mat& src, Mat& dst, float lambda, const int interpolation,const TPS_INTERPOLATION tpsInter)
{
Size size = src.size();
dst = Mat(size,src.type());
// only compute the coefficients new if they weren't already computed
// or there had been changes to the points
if(tpsInter == BACK_WARP && !FLAG_COEFFS_BACK_WARP_SET)
{
computeSplineCoeffs(pSrc,pDst,lambda,tpsInter);
}
else if(tpsInter == FORWARD_WARP && !FLAG_COEFFS_FORWARD_WARP_SET)
{
computeSplineCoeffs(pSrc,pDst,lambda,tpsInter);
}
computeMaps(size,mapx,mapy);
remap(src,dst,mapx,mapy,interpolation);
}
有就是中存在的联系也CthinPlateSpline.cpp和CthinPlateSpline.h其他类......请我真的需要帮助,对不起我的英文不好
there is to other classes that exist in the link also CthinPlateSpline.cpp and CthinPlateSpline.h ...please i really need help and sorry for my bad english
推荐答案
我可以在我的Mac上运行的OpenCV这些2.4.7
I can run these on my mac with OpenCV 2.4.7
结果图像是一个扭曲的莉娜
The result image is a twisted lena
我只是改变两个地方如下
I just change two places as following
首先,我更改包括文件main.cpp中成为
First of all, I change the included file in main.cpp to become
#include <opencv2/opencv.hpp>
#include "CThinPlateSpline.h"
#include <iostream>
#include <vector>
和包含在CThinPlateSpline.cpp文件成为
And included file in CThinPlateSpline.cpp to become
#include <vector>
#include <opencv2/opencv.hpp>
#include "CThinPlateSpline.h"
我只用3个文件main.cpp中,CThinPlateSpline.cpp和CThinPlateSpline.h
I use only 3 files main.cpp, CThinPlateSpline.cpp, and CThinPlateSpline.h
链接库
-lopencv_imgproc -lopencv_core -lopencv_highgui
-lopencv_imgproc -lopencv_core -lopencv_highgui
这篇关于断言失败&LT; dst.data = src.data&GT!;在未知功能../../ocv/opencv/modules/imgproc/src/imgwarp.cpp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!