Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Exception OpenCV
I am trying to do the examples in the OpenCV book and I got to the part regarding cvSmooth. I am trying to use it, but I keep getting a memory exception error of
 
Unhandled exception at 0x757dd36f in smoothing.exe: Microsoft C++ exception: cv::Exception at memory location 0x0036f6d4..
 
I have also looked at another post that was similar to this question, but it did not help for me as I got the same error each time. Any help is greatly appreciated and the source code for the function is located below.
#include "stdafx.h"
#include <cv.h>
#include <highgui.h>
#include "iostream"
 
using namespace std;
 
void smoothing(IplImage *image)
{
	//create some window to show the input and output image
	cvNamedWindow("smoothing-in");
 
	cvNamedWindow("smoothing-out");
 
	//window that show our input image
	cvShowImage("smoothing-in",image);
 
	//create an image to hold smoothed output
	IplImage *output = cvCreateImage(
		cvGetSize(image),
		IPL_DEPTH_8U,
		3
		);
	//do the smoothing
	cvSmooth(image,output,CV_GAUSSIAN,3,3);
 
	//show the smoothed image
	cvShowImage("smoothing:",output);
 
	cvReleaseImage(&output);
	cvWaitKey(0);
	cvDestroyWindow("smoothing-in");
	cvDestroyWindow("smoothing-out");
}
int _tmain(int argc, _TCHAR* argv[])
{
	IplImage *img = NULL;//cvLoadImage("image.jpg");
	if((img = cvLoadImage("image.jpg")) == 0){
		cout<<"image load failed";
	}
	smoothing(img);
	cvReleaseImage(&img);
	return 0;
}
thank !
 
Posted 30-Jun-12 8:13am
Comments
Code-o-mat at 2-Jul-12 6:30am
   
Where do you get that exception?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I think you must find out where is your image.jpg & where is your application
 

if((img = cvLoadImage("image.jpg")) == 0){
        cout<<"image load failed";
    }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 474
1 ridoy 420
2 DamithSL 180
3 OriginalGriff 179
4 Richard MacCutchan 160
0 OriginalGriff 8,033
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,538
3 Maciej Los 5,508
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web04 | 2.8.141223.1 | Last Updated 13 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100