我使用openCV将视频读入Visual Studio并将其转换为灰度,然后使用函数CV_THRESH_BINARY将其转换为二进制图像.但是,框架中存在孔洞和噪音.什么是消除噪音或漏洞的简单方法?我已经阅读了openCV中的Erode和Dilate函数,但我对如何使用它们并不太清楚.到目前为止这是我的代码.如果有人能告诉我如何将噪声消除结合到我的代码中,我们将不胜感激.
#include "cv.h"
#include "highgui.h"
int main( int argc, char* argv ) {
CvCapture *capture = NULL;
capture = cvCaptureFromAVI("C:\\walking\\lady walking.avi");
if(!capture){
return -1;
}
IplImage* color_frame = NULL;
IplImage* gray_frame = NULL ;
int thresh_frame = 70;
int frameCount=0;//Counts every 5 frames
cvNamedWindow( "Binary video", CV_WINDOW_AUTOSIZE );
while(1) {
color_frame = cvQueryFrame( capture );//Grabs the frame from a file
if( !color_frame ) break;
gray_frame = cvCreateImage(cvSize(color_frame->width, color_frame->height), color_frame->depth, 1);
if( !color_frame ) break;// If the frame does not …
Run Code Online (Sandbox Code Playgroud) #include "cv.h"
#include "highgui.h"
int main(int argc, char** argv)
{
CvCapture* capture=0;
IplImage* frame=0;
capture = cvCaptureFromAVI("C:\\boy walking back.avi"); // read AVI video
if( !capture )
throw "Error when reading steam_avi";
cvNamedWindow( "w", 1);
for( ; ; )
{
/* int cvGrabFrame (CvCapture* capture);
IplImage* cvRetrieveFrame (CvCapture* capture)*/
frame = cvQueryFrame( capture );
if(!frame)
break;
cvShowImage("w", frame);
}
cvWaitKey(0); // key press to close window
cvDestroyWindow("w");
cvReleaseImage(&frame);
}
Run Code Online (Sandbox Code Playgroud)
我在VS2008上使用openCV.我已经在视频文件中读取并使用CV_CAP_PROP_FRAME_COUNT来获得对于4秒长视频剪辑大约为130的帧数.我正在对行走进行运动识别,因此我需要在5帧之间获得每隔5帧,身体的运动几乎没有变化.到目前为止我有一个程序,它允许我获得一帧视频剪辑.但是,我无法获得不同的帧,而且,我不知道如何获得每隔5帧.以上是用于获取视频的一帧的代码.
我正在使用openCV在C++中实现一个图像处理算法,其中第一步要求将图像转换为矩阵.我知道当图像加载到openCV中时,它已经存储为矩阵.我使用的图像大小为80 x 60,所以我假设它存储的矩阵大小为80 x 60.但是,我想首先能够看到这个矩阵然后能够重塑它变成了一个相同的矩阵.像素,但作为一个长列.即80×60矩阵现在将成为4800×1矩阵.我曾尝试过研究教科书和在线但无济于事.到目前为止这是我的代码.在任何情况下,它都无法正常工作,因为我无法将'IplImage*'转换为'CvMat*但是我应该如何在创建后将像素值分配给矩阵?如果有人可以帮我解决这个问题,我将不胜感激.
#include "cv.h"
#include "highgui.h"
#include "iostream"
using namespace std;
int main( int argc, char* argv ) {
IplImage* img0 = NULL;
CvMat* img0_mat = NULL ;
img0 = cvLoadImage("C:\\new\\walk mii.jpg");
if (!img0){
return -1;}
img0_mat = cvCreateMat(80, 60, 1);
img0_mat = img0;
cout <<" matrix " << img0 << endl;
cvWaitKey(0);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我想提取二进制图像的白色区域.无论我在互联网上查看,我都会看到有关cvBlob和cvBlobLib的内容.我真的不知道这些是什么,因为我只是使用openCV和C++.我是否需要安装这些额外的东西来从我的二进制图像中提取白色区域.白色区域是一个人走路.