我正在尝试做一个非常简单的程序,使用Opencv来反转像素的位置。然而,由于某种原因,代码似乎不能计算,我已经注意到很多丢失的PDB文件&我做了一些研究,但我还没有找到任何东西来帮助我解决我正在使用的VS2010和Opencv 2.2的问题
#include "stdafx.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <iostream>
using namespace std ;
int _tmain(int argc, _TCHAR* argv[]){
IplImage *image = cvLoadImage("mra.jpg");
if (!image) {
cout<<"Error: Couldn't open the image file.\n"<<endl ;
return 1;
}
IplImage *new_image = cvCreateImage(cvGetSize(image) , image->depth , 1 );
CvScalar pix ;
int position = 0 ;
for(int i = 0 ; i < image->height ; i++ ){
for (int j = 0 ; j < image->width ; j++ ){
pix = cvGet2D(image , i , j ) ;
if ( i = 0 ){
position = image->height - 1 ;
}else if ((position >= 2)) {
position = position - 2 ;
}
cvSet2D(new_image , position , j , pix );
}
}
cvNamedWindow("1111", CV_WINDOW_AUTOSIZE);
cvNamedWindow("2222", CV_WINDOW_AUTOSIZE);
cvShowImage("1111", image);
cvShowImage("2222", new_image);
// Wait for the user to press a key in the GUI window.
cvWaitKey(0);
// Free the resources.
cvDestroyAllWindows ;
cvReleaseImage(&image);
cvReleaseImage(&new_image);
return 0;
}提前感谢
发布于 2011-02-09 04:17:42
如果(i = 0)
将0赋值给i,应该是(i == 0)。你是否碰巧得到了一个无尽的循环?
https://stackoverflow.com/questions/4708810
复制相似问题