Tag: opencv

计算关键点的新位置

有人可以帮助我,如何计算变换图像中关键点的新位置,在原始图像中检测关键点。 我使用opencv单应矩阵和warpPerspective来制作转换后的图像。 这是一个代码.. … std::vector points1,points2; for( int i = 0; i < matches1.size(); i++ ) { points1.push_back( keypoints_input1[matches1[i].queryIdx ].pt ); points2.push_back( keypoints_input2[matches1[i].trainIdx ].pt ); } /* Find the Homography Matrix for current and next frame*/ Mat H1 = findHomography( points2, points1, CV_RANSAC ); /* Use the Homography Matrix to warp the images*/ cv::Mat result1; […]

使用openCV与fftw3 Visual Studio 2010的链接器错误

我在同一个项目中尝试使用openCV来实现fftw3时遇到了麻烦。 我是c / c ++的新手,非常感谢任何帮助。 以下是我使用的示例代码: #include “fftw3.h” #include int main(){ fftw_complex *in, *out; fftw_plan p; int N=8; in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N); p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE); for(int i=0; i<N; i++){ in[i][0]=i; in[i][1]=0; } fftw_execute(p); for(int i=0; i%f\tI->%f\n”, out[i][0], out[i][1]); } system(“pause”); fftw_destroy_plan(p); fftw_free(in); fftw_free(out); […]

opencv背景减法获取颜色对象

我已经使用下面的教程来做背景减法, http://docs.opencv.org/master/d1/dc5/tutorial_background_subtraction.html#gsc.tab=0 但是使用pMOG2->apply( frame, fgMaskMOG2 )方法将输出返回为二进制图像。 在删除背景或使用二进制图像获取彩色图像后,是否有任何方法只能获取颜色对象?

OpenCV Mat函数返回并使用copyTo

我有这个片段来执行齐次矩阵的逆 Mat invHom(const Mat A) { Mat invA = Mat::eye(4,4,CV_64FC1); Mat R, P; A(Range(0,3), Range(0,3)).copyTo(R); A(Range(0,3), Range(3,4)).copyTo(P); invA(Range(0,3), Range(0,3)) = Rt(); invA(Range(0,3), Range(3,4)) = -Rt()*P; return invA; } 这段代码往往会出错吗? 因为invA,R,P是在函数范围内创建的Mat。 函数的“返回”是否执行创建和复制到新的Mat对象(即Mat :: copyTo()),以便在函数外部仍然可以使用invA的值? 抱歉我的英语不好和编程条款 一个没有错误: int invHom(const Mat A, Mat& invA_ou) { Mat invA = Mat::eye(4,4,CV_64FC1); Mat R, P; A(Range(0,3), Range(0,3)).copyTo(R); A(Range(0,3), Range(3,4)).copyTo(P); //invA(Range(0,3), Range(0,3)) […]

如何在OpenCV中创建描述符矩阵

如何在OpenCV中创建一个描述符,该描述符可以与OpenCV中的一个DescriptorMatcher一起使用,方式如下。 cv::BFMatcher matcher( cv::NORM_L2, false ); std::vector matches; matcher.match( descriptors_1, descriptors_2, matches ); 我已经有了以下描述符类。 如何转换或创建可与DescriptorMatcher一起使用的新矩阵。 最好是BFMatcher。 class Descriptor { public: float lxi, lyi; // Location of descriptor vector feature; Descriptor() { } Descriptor(float x, float y, vector const& f) { lxi = x; lyi = y; feature = f; } };

cvCaptureFromFile-从特定路径打开video – Raspberry Pi

我在Raspberry Pi中安装了OpenCV-2.4.9。 现在我正在尝试从特定路径加载video,为此我尝试使用C和C ++ API C API:cvCaptureFromFile(path); C ++ API:VideoCapture上限; cap.open(路径) 我收到错误,它说无法打开文件。 它适用于Windows和Linux,但不适用于Raspberry Pi。 我错过了什么吗? C ++代码: #include #include #include #include #include using namespace cv; using namespace std; int main(){ VideoCapture cap(“C:/Users/nava/Videos/file.mp4”); if (!cap.isOpened()){ cout << "Error opening video stream" << endl; return -1; } while (1){ Mat Frame; if (!cap.read(Frame)){ cout << "No Frame […]

断言失败在未知函数中../../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 #include #include #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 […]

如何使用C ++ Mat类ptr对象的基本C包装器打印Mat元素

我正在为一些OpenCV C ++代码编写一个C包装器,我有2个函数用于创建Mat对象并分别将数据设置为cv_create_Mat_type和cv_Mat_ptr_index。 function是他们需要的,我无法改变它们,因为我正在与某人合作完成项目的一部分。 我的问题是如何打印cv_Mat_ptr_index填充的矩阵,因为它填充了for循环内部。 cv_Mat_ptr_index上的返回是一个uchar *我尝试解除引用但是我需要知道如何获取cv_Mat_ptr_index(uchar *)返回内部的数据,因为我确定,如果我错了就纠正我,那就是它包含当前从以下代码中的数据数组分配到矩阵mat中的元素。 提前感谢任何参与者。 #include “opencv2/highgui/highgui.hpp” #include “opencv2/highgui/highgui_c.h” #include using namespace cv; using namespace std; uchar* cv_Mat_ptr_index(Mat* self, int i) { return self->ptr(i); } Mat* cv_create_Mat_typed(int rows, int cols, int type) { return new Mat(rows, cols, type); } int main( ) { float data[4][2] = { {501, 10}, {255, 10}, […]

OpenCv在Visual Studio中未解决外部符号错误

我已链接到我想要使用的库,并将头文件添加到我的项目中。 并且代码在红色波形中没有显示任何错误,但是当我尝试运行它时,它给出了以下错误: Error 1 error LNK2001: unresolved external symbol _cvDestroyWindow C:\Users\Jos\documents\visual studio 2010\Projects\ocv\ocv\opcv.obj ocv Error 2 error LNK2001: unresolved external symbol _cvWaitKey C:\Users\Jos\documents\visual studio 2010\Projects\ocv\ocv\opcv.obj ocv Error 3 error LNK2001: unresolved external symbol _cvNamedWindow C:\Users\Jos\documents\visual studio 2010\Projects\ocv\ocv\opcv.obj ocv Error 4 error LNK2001: unresolved external symbol _cvLoadImage C:\Users\Jos\documents\visual studio 2010\Projects\ocv\ocv\opcv.obj ocv Error 5 error LNK2001: unresolved […]

将图像推入Gstreamer管道

我一直在关注将图像推送到Gstreamer管道的许多例子,但我仍然无法使我的代码工作。 任何建议(除了告诉我尝试使用Gstreamer1.0而不是0.10)将非常感激。 我想了解以下脚本中的错误,该脚本使用jpeg图像提供appsrc元素。 稍后我将使用相同的代码来提供我从相机中获取的openCv图像,但首先我想通过使这个简单的示例工作来理解基础知识。 #include #include #include #include #include #define VIDEO_CAPS “video/x-raw-rgb,bpp=8,depth=8,width=640,height=360,framerate=5/1,red_mask=224,green_mask=28,blue_mask=3,endianness=1234;” /* Structure to contain all our information, so we can pass it to callbacks */ guint64 imagecounter=1; typedef struct _CustomData { GstElement *pipeline, *app_source; GstElement *video_convert, *video_sink; GstElement *image_manage; guint64 num_samples; /* Number of samples generated so far (for timestamp generation) */ guint […]