2013-12-19 70 views
0

嘿,請有人可以幫我找到這個錯誤的解決方案:聲明失敗<dst.data!= src.data>在未知函數中../../ocv/opencv/modules/imgproc/src/imgwarp.cpp

斷言未知功能../../ocv/opencv/modules/imgproc/src/imgwarp.cpp失敗

我嘗試編譯存在於這個鏈接的代碼:http://ipwithopencv.googlecode.com/svn/trunk/ThinPlateSpline/ThinPlateSpline/

即時通訊使用2類和主要:

這裏是我的主要代碼:

#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方法:

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其他類......請我真的需要幫助,對不起因爲我的英文不好

+0

你展示的代碼是與問題無關。請發掘src爲tps.warpImage() – berak

+0

[鏈接](http://ipwithopencv.googlecode.com/svn/trunk/ThinPlateSpline/ThinPlateSpline/CThinPlateSpline.cpp)這裏是ThinPlateSplace.cpp所有定義方法的存在 – KhaliliP

+0

哦,請編輯你的問題,所以它變得更可讀;) – berak

回答

0

我可以用的OpenCV 2.4.7

結果圖像是扭曲的莉娜

我只是改變兩個地方如下

首先在我的Mac上運行這些,我改變包括文件中的main.cpp成爲

#include <opencv2/opencv.hpp> 
#include "CThinPlateSpline.h" 
#include <iostream> 
#include <vector> 

並列入文件中CThinPlateSpline.cpp成爲

#include <vector> 
#include <opencv2/opencv.hpp> 
#include "CThinPlateSpline.h" 

我只用3個文件main.cpp中,CThinPlateSpline.cpp和CThinPlateSpline.h

庫鏈接是

-lopencv_imgproc -lopencv_core -lopencv_highgui

+0

最後它運作親愛的@ maythe4thbewithu我非常感謝你幫我 – KhaliliP

+0

那麼路徑有什麼問題? – maythe4thbewithu

+0

抱歉,親愛的可能因此沒有回答所有這一次,問題是在庫我混合釋放和調試庫在visual studio – KhaliliP

0

OpenCV中的「聲明失敗」通常發生在您的輸入墊子的大小不正確時,例如零(空Mat)或小於該功能的要求。

你介意檢查IMGcv::Mat img = cv::imread("lena.jpg"); 由img.empty()或顯示IMG通過imshow後?

+0

感謝maythe4thbewithu我試過後cv :: Mat img = cv :: imread(「lena.jpg」); this:if(img.empty()== true){std :: cout <<「空圖像「<< endl;}結果是空圖像..是圖像位置的問題或什麼exactely .. can you help me please – KhaliliP

+0

@younestheboss我可以在我的Mac上運行這些(main.cpp,CThinPlateSpline.cpp,CThinPlateSpline.h)與OpenCV 2.4.7,結果圖像是扭曲的莉娜。 – maythe4thbewithu

+0

即時通訊使用opencv2.2我總是有同樣的問題,我試圖改變圖像的位置,但仍然有同樣的錯誤@ maythe4thbewithu非常感謝你的幫助 – KhaliliP