opencv程序可以运行,但是不显示图像,怎么解决?
附程序如下,运行环境为VS2010#include"cv.h"#include"highgui.h"#include"math.h"intmain(intargc,cha...
附程序如下,运行环境为VS2010
#include "cv.h"
#include "highgui.h"
#include "math.h"
int main(int argc, char** argv)
{
IplImage* src = 0;
/* the first command line parameter must be image file name */
if(argc == 2&&(src = cvLoadImage(argv[1],-1))!= 0)
{
IplImage* dst = cvCloneImage(src);
int delta = 1;
int angle = 0;
int opt = 1; //1:旋转加缩放
//0:旋转
double factor;
cvNamedWindow("src",1);
cvShowImage("src",src);
for(;;)
{
float m[6];
//Matrix m looks like:
//
//[m0 m1 m2] ===> [A11 A12 b1]
//[m3 m4 m5] [A21 A22 b2]
//
CvMat M = cvMat(2,3,CV_32F,m);
int w = src->width;
int h = src->height;
if(opt) //旋转加缩放
factor = (cos(angle*CV_PI/180.)+1.05)*2;
else //仅仅旋转
factor = 1;
m[0] = (float)(factor*cos(-angle*2*CV_PI/180.));
m[1] = (float)(factor*sin(-angle*2*CV_PI/180.));
m[3] = -m[1];
m[4] = m[0];
//将旋转中心移至图像中间
m[2] = w*0.5f;
m[5] = h*0.5f;
// dst(x,y) = A*src(x,y)+b
cvGetQuadrangleSubPix(src,dst,&M);
cvNamedWindow("dst",1);
cvShowImage("dst",dst);
if(cvWaitKey(5) == 27)
break;
angle = (int)(angle + delta)%360;
} //for-loop
}
return 0;
}
将图片命名为src放在工程文件夹里,问题如上 展开
#include "cv.h"
#include "highgui.h"
#include "math.h"
int main(int argc, char** argv)
{
IplImage* src = 0;
/* the first command line parameter must be image file name */
if(argc == 2&&(src = cvLoadImage(argv[1],-1))!= 0)
{
IplImage* dst = cvCloneImage(src);
int delta = 1;
int angle = 0;
int opt = 1; //1:旋转加缩放
//0:旋转
double factor;
cvNamedWindow("src",1);
cvShowImage("src",src);
for(;;)
{
float m[6];
//Matrix m looks like:
//
//[m0 m1 m2] ===> [A11 A12 b1]
//[m3 m4 m5] [A21 A22 b2]
//
CvMat M = cvMat(2,3,CV_32F,m);
int w = src->width;
int h = src->height;
if(opt) //旋转加缩放
factor = (cos(angle*CV_PI/180.)+1.05)*2;
else //仅仅旋转
factor = 1;
m[0] = (float)(factor*cos(-angle*2*CV_PI/180.));
m[1] = (float)(factor*sin(-angle*2*CV_PI/180.));
m[3] = -m[1];
m[4] = m[0];
//将旋转中心移至图像中间
m[2] = w*0.5f;
m[5] = h*0.5f;
// dst(x,y) = A*src(x,y)+b
cvGetQuadrangleSubPix(src,dst,&M);
cvNamedWindow("dst",1);
cvShowImage("dst",dst);
if(cvWaitKey(5) == 27)
break;
angle = (int)(angle + delta)%360;
} //for-loop
}
return 0;
}
将图片命名为src放在工程文件夹里,问题如上 展开
展开全部
附程序如下,运行环境为VS2010
#include "cv.h"
#include "highgui.h"
#include "math.h"
int main(int argc, char** argv)
{
IplImage* src = 0;
/* the first command line parameter must be image file name */
if(argc == 2&&(src = cvLoadImage(argv[1],-1))!= 0)
{
IplImage* dst = cvCloneImage(src);
int delta = 1;
int angle = 0;
int opt = 1; //1:旋转加缩放
//0:旋转
double factor;
cvNamedWindow("src",1);
cvShowImage("src",src);
for(;;)
{
float m[6];
//Matrix m looks like:
//
//[m0 m1 m2] ===> [A11 A12 b1]
//[m3 m4 m5] [A21 A22 b2]
//
CvMat M = cvMat(2,3,CV_32F,m);
int w = src->width;
int h = src->height;
if(opt) //旋转加缩放
factor = (cos(angle*CV_PI/180.)+1.05)*2;
else //仅仅旋转
factor = 1;
m[0] = (float)(factor*cos(-angle*2*CV_PI/180.));
m[1] = (float)(factor*sin(-angle*2*CV_PI/180.));
m[3] = -m[1];
m[4] = m[0];
//将旋转中心移至图像中间
m[2] = w*0.5f;
m[5] = h*0.5f;
// dst(x,y) = A*src(x,y)+b
cvGetQuadrangleSubPix(src,dst,&M);
cvNamedWindow("dst",1);
cvShowImage("dst",dst);
if(cvWaitKey(5) == 27)
break;
angle = (int)(angle + delta)%360;
} //for-loop
}
return 0;
}
将图片命名为src放在工程文件夹里,问题如上
#include "cv.h"
#include "highgui.h"
#include "math.h"
int main(int argc, char** argv)
{
IplImage* src = 0;
/* the first command line parameter must be image file name */
if(argc == 2&&(src = cvLoadImage(argv[1],-1))!= 0)
{
IplImage* dst = cvCloneImage(src);
int delta = 1;
int angle = 0;
int opt = 1; //1:旋转加缩放
//0:旋转
double factor;
cvNamedWindow("src",1);
cvShowImage("src",src);
for(;;)
{
float m[6];
//Matrix m looks like:
//
//[m0 m1 m2] ===> [A11 A12 b1]
//[m3 m4 m5] [A21 A22 b2]
//
CvMat M = cvMat(2,3,CV_32F,m);
int w = src->width;
int h = src->height;
if(opt) //旋转加缩放
factor = (cos(angle*CV_PI/180.)+1.05)*2;
else //仅仅旋转
factor = 1;
m[0] = (float)(factor*cos(-angle*2*CV_PI/180.));
m[1] = (float)(factor*sin(-angle*2*CV_PI/180.));
m[3] = -m[1];
m[4] = m[0];
//将旋转中心移至图像中间
m[2] = w*0.5f;
m[5] = h*0.5f;
// dst(x,y) = A*src(x,y)+b
cvGetQuadrangleSubPix(src,dst,&M);
cvNamedWindow("dst",1);
cvShowImage("dst",dst);
if(cvWaitKey(5) == 27)
break;
angle = (int)(angle + delta)%360;
} //for-loop
}
return 0;
}
将图片命名为src放在工程文件夹里,问题如上
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
加上显示的时间
cvWaitkey();//里边可以加上显示时间
cvWaitkey();//里边可以加上显示时间
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询