probably a simple error

I am trying to write a program that creates a hybrid image I've hit a roadblock early on my code throws up an unhandeled exception I cant find where it goes wrong I need a fresh perspective on this.

here is my code so far

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <cv.h>  
#include <highgui.h>  
#include <stdio.h>    
using namespace cv;  
Point P11, P12;
Point P21, P22;
int cc1 = 0, cc2 = 0;

void on_mouse1 (int event, int x, int y, int flags, void *param);   
void on_mouse2 (int event, int x, int y, int flags, void *param);
void hybridImage(cv::Mat img1, cv::Mat img2, int ksize, double sigma, cv::Mat& img12);
void Myalignment (cv::Mat img1, Point p11, Point p12, cv::Mat img2, Point p21, Point p22, cv::Mat& aligned_img1, cv::Mat& aligned_img2 );

int  main (int argc, char *argv[])  
{    
	int c; 
	int ksize = 61;
	double sigma = 50; 

	cv::Mat img1 = cv::imread( "JunbinPicture.jpg"); // ( argv[1] ); 
	cv::Mat img2 = cv::imread(  "nutmeg.jpg");  // argv[2] ); 
	cv::Mat aligned_img1, aligned_img2, img12;   

	cv::namedWindow ("Image 1", CV_WINDOW_AUTOSIZE);  
	//Set mouse handler for window 1
	cv::setMouseCallback ("Image 1", on_mouse1);    
	cv::imshow ("Image 1", img1);  

	cv::namedWindow ("Image 2", CV_WINDOW_AUTOSIZE); 
	//Set mouse handler for window 2
	cvSetMouseCallback ("Image 2", on_mouse2);    
	cv::imshow ("Image 2", img2);  

	cv::namedWindow ("Image Hybrid", CV_WINDOW_AUTOSIZE); 
	 
	while (1) {      
		c = cvWaitKey (0);   
		if (c == 'c' || c == 'C' ) {  //If press "c", then calculate the hybrid image
			 //call your alignment algorithm);
			 //
			 // Dispalay the aligned images
			 //
			 //Call your hybrid algorithm 
			 //Display and write results 
			cout<< "Call your algorithms! " << endl;
		}
		if (c == '\x1b')    // Press "ESC" to exit   
			return 1;    
	}         
	return 0;  
}


can anyone see what I'm missing ?
At what point in the execution does it throw the exception? What sort of exception is being thrown?
the code executes the console window pops up and says

OpenCV Error: Bad flag <parameter or structure field> <unrecognised or unsupported array type> in unknown function, file ..\..\..\..\ocv\opencv\modules\core\src\array.cpp, line 2480


then the window for image 1 pops up blank and it throws the exception

Unhandeled exception at 0x75d5812f in 368.exe: Microsoft C++ exception: cv::Exception at memory location 0x0026e3e0..
So, cv throws an exception and you don't catch it.

Maybe you should check the documentation for the functions you are using and code accordingly.
it should be upto spec this code is just the set up I haven't started trying to align the pictures yet could it be somthing like the program not finding the image files
I found where the problem occurs line 29 and line 34
cv::imshow ("Image 1", img1);

and

cv::imshow ("Image 2", img2);

but I still dont know how to fix it
Topic archived. No new replies allowed.