Reputation: 2824
i am trying to make a very simple program that invert the pixels position using Opencv .. however it seems that the code doez not compute for some reason , i have noticed a lot of Missing PDB files & i made a little research but i havent find any thing to help me solve the problem i am using VS 2010 with 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;
}
thanks in advance
Upvotes: 1
Views: 855
Reputation: 2058
if (i = 0)
will assign 0 to i. It should be (i == 0). Are you by any chance getting an endless loop?
Upvotes: 1