【发布时间】:2012-03-14 21:49:57
【问题描述】:
我正在尝试使用开放式 CV FAST 算法来检测视频源中的角点。方法调用和设置似乎很简单,但我遇到了一些问题。当我尝试使用此代码时
while(run)
{
clock_t begin,end;
img = cvQueryFrame(capture);
key = cvWaitKey(10);
cvShowImage("stream",img);
//Cv::FAST variables
int threshold=9;
vector<KeyPoint> keypoints;
if(key=='a'){
//begin = clock();
Mat mat(tempImg);
FAST(mat,keypoints,threshold,true);
//end = clock();
//cout << "\n TIME FOR CALCULATION: " << double(diffClock(begin,end)) << "\n" ;
}
我收到此错误:
OpenCV 错误:断言失败 (image.data && image.type() == CV_8U) 未知 函数,文件........\ocv\opencv\src\cvaux\cvfast.cpp,第 6039 行
所以我认为这是图像深度的问题,所以当我添加这个时:
IplImage* tempImg = cvCreateImage(Size(img->width,img->height),8,1);
cvCvtColor(img,tempImg,CV_8U);
我明白了:
OpenCV 错误:通道数错误(此转换的通道数不正确 版本代码)在未知函数中,文件........\ocv\opencv\src\cv\cvcolor.cpp ,第 2238 行
我尝试使用 Mat 而不是 IplImage 进行捕获,但我不断收到相同类型的错误。
有什么建议或帮助吗? 提前致谢。
整个文件只是为了方便任何人:
#include "cv.h"
#include "cvaux.hpp"
#include "highgui.h"
#include <time.h>
#include <iostream>
double diffClock(clock_t begin, clock_t end);
using namespace std;
using namespace cv;
int main(int argc, char** argv)
{
//Create Mat img for camera capture
IplImage* img;
bool run = true;
CvCapture* capture= 0;
capture = cvCaptureFromCAM(-1);
int key =0;
cvNamedWindow("stream", 1);
while(run)
{
clock_t begin,end;
img = cvQueryFrame(capture);
key = cvWaitKey(10);
cvShowImage("stream",img);
//Cv::FAST variables
int threshold=9;
vector<KeyPoint> keypoints;
if(key=='a'){
//begin = clock();
IplImage* tempImg = cvCreateImage(Size(img->width,img->height),8,1);
cvCvtColor(img,tempImg,CV_8U);
Mat mat(img);
FAST(mat,keypoints,threshold,true);
//end = clock();
//cout << "\n TIME FOR CALCULATION: " << double(diffClock(begin,end)) << "\n" ;
}
else if(key=='x'){
run= false;
}
}
cvDestroyWindow( "stream" );
return 0;
}
【问题讨论】:
标签: c++ c visual-c++ opencv