Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Access Violation with imread

Hi all !

I'm trying to use imread to open an image that I write just before, here is my code (sorry, some is in French =) ):

// essais.cpp : définit le point d'entrée pour l'application console.

#include "stdafx.h"
////////////////////////
//**Premiers essais**//
///////////////////////

#include "opencv2/opencv.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{

//**Variables
    printf("Initialisation variables\n");
    CvCapture *avi;
    IplImage* im;
    Mat immat, imthresh;
    Mat imde, imcanny;
    char* trackbar_value = "Valeur";    
    cvNamedWindow("acquisition", CV_WINDOW_AUTOSIZE );
    namedWindow("binaire", CV_WINDOW_AUTOSIZE );
    namedWindow("dne", CV_WINDOW_AUTOSIZE );
    namedWindow("cont", CV_WINDOW_AUTOSIZE );

//**Ouverture de la video
    printf("Ouverture video\n");
    avi = cvCaptureFromFile("G:\\Anthias\\Output16_boncontraste_bonneglisse_toAVI.avi");

    if (!avi)
    { 
        printf("Video non ouverte");
        return -1;}

//**Recuperation de la dernière image de la video
    while(cvGrabFrame(avi))
        im = cvQueryFrame(avi);

    cvShowImage("acquisition",im);
    cvSaveImage("image.jpg",im);

//**Traitement de l'image   

//**Récupération de l'image en tant que Mat
    printf("Traitement image\n");                                               
    printf("ouverture de l'image...");
    immat = imread( "G:/Anthias/OpenCV/Essais/essais/essais/image.jpg", 1 );

    if (immat.empty())
    { 
        printf("Image non ouverte\n");
        cvWaitKey();
        return -2;}
    else {printf("Image ouverte\n");}

    imshow("binaire",immat);
    cvWaitKey();

Everything works, until imread, it crashes and I've an error message :

Unhandled exception at 0x7854fdf1 (msvcr90d.dll) in essais.exe: 0xC0000005: Access
 violation reading location 0xCCCCCCCC.

I've seen a question where someone had the same error, but his solution is not mine,

The problem was in environmental variable path, there was for version vs2008 and next for 2012.

I'm using opencv 2.4.1 with Visual Studio 2008, and I've nothing concerning the 2012 version in my path so... IDK xD

I suppose there is something wrong in my environment or whatever, but I can't figure out what it is, and I'm searching for sooo long now ... Please help me ! =) xD

If you need some more infos, just tell me and I'll edit ;)

Thanks all =)

Access Violation with imread

Hi all !

I'm trying to use imread to open an image that I write just before, here is my code (sorry, some is in French =) ):

// essais.cpp : définit le point d'entrée pour l'application console.

#include "stdafx.h"
////////////////////////
//**Premiers essais**//
///////////////////////

#include "opencv2/opencv.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{

//**Variables
    printf("Initialisation variables\n");
    CvCapture *avi;
    IplImage* im;
    Mat immat, imthresh;
    Mat imde, imcanny;
    char* trackbar_value = "Valeur";    
    cvNamedWindow("acquisition", CV_WINDOW_AUTOSIZE );
    namedWindow("binaire", CV_WINDOW_AUTOSIZE );
    namedWindow("dne", CV_WINDOW_AUTOSIZE );
    namedWindow("cont", CV_WINDOW_AUTOSIZE );

//**Ouverture de la video
    printf("Ouverture video\n");
    avi = cvCaptureFromFile("G:\\Anthias\\Output16_boncontraste_bonneglisse_toAVI.avi");

    if (!avi)
    { 
        printf("Video non ouverte");
        return -1;}

//**Recuperation de la dernière image de la video
    while(cvGrabFrame(avi))
        im = cvQueryFrame(avi);

    cvShowImage("acquisition",im);
    cvSaveImage("image.jpg",im);

//**Traitement de l'image   

//**Récupération de l'image en tant que Mat
    printf("Traitement image\n");                                               
    printf("ouverture de l'image...");
    immat = imread( "G:/Anthias/OpenCV/Essais/essais/essais/image.jpg", 1 );

    if (immat.empty())
    { 
        printf("Image non ouverte\n");
        cvWaitKey();
        return -2;}
    else {printf("Image ouverte\n");}

    imshow("binaire",immat);
    cvWaitKey();

Everything works, until imread, it crashes and I've an error message :

Unhandled exception at 0x7854fdf1 (msvcr90d.dll) in essais.exe: 0xC0000005: Access
 violation reading location 0xCCCCCCCC.

I've seen a question where someone had the same error, but his solution is not mine,

The problem was in environmental variable path, there was for version vs2008 and next for 2012.

I'm using opencv 2.4.1 with Visual Studio 2008, and I've nothing concerning the 2012 version in my path so... IDK xD

I suppose there is something wrong in my environment or whatever, but I can't figure out what it is, and I'm searching for sooo long now ... Please help me ! =) xD

If you need some more infos, just tell me and I'll edit ;)

Thanks all =)

EDIT 1 :

// essais.cpp : définit le point d'entrée pour l'application console.

#include "stdafx.h"
////////////////////////
//**Premiers essais**//
///////////////////////

#include "opencv2/opencv.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <opencv2 core="" core.hpp="">

using namespace cv;
using namespace std;


int main(int argc, char** argv)
{

//**Variables
    printf("Initialisation variables\n");
    VideoCapture avi;
    Mat im, immat; 
    Mat imde, imcanny, imthresh;
    char* trackbar_value = "Valeur";    
    cvNamedWindow("acquisition", CV_WINDOW_AUTOSIZE );
    namedWindow("binaire", CV_WINDOW_AUTOSIZE );
    namedWindow("dne", CV_WINDOW_AUTOSIZE );
    namedWindow("cont", CV_WINDOW_AUTOSIZE );

//**Ouverture de la video
    printf("Ouverture video\n");
    avi = VideoCapture("G:/Anthias/Output16_boncontraste_bonneglisse_toAVI.avi");

    if (!avi.isOpened())
    { 
        printf("Video non ouverte");
        return -1;}

I've re-write all my code in C++, and now I've got the same kind of error, but with VideoCapture :

Unhandled exception at 0x77c17bec in essais.exe: 0xC0000005: Access
 violation reading location 0xCCCCCCCC.

I think this is why I started to write using C style, and then changed to C++ style because I realised It was better to use C++ for next parts.

What stuff am I mixing ?!

Thanks again =)

Access Violation with imread

Hi all !

I'm trying to use imread to open an image that I write just before, here is my code (sorry, some is in French =) ):

// essais.cpp : définit le point d'entrée pour l'application console.

#include "stdafx.h"
////////////////////////
//**Premiers essais**//
///////////////////////

#include "opencv2/opencv.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv)
{

//**Variables
    printf("Initialisation variables\n");
    CvCapture *avi;
    IplImage* im;
    Mat immat, imthresh;
    Mat imde, imcanny;
    char* trackbar_value = "Valeur";    
    cvNamedWindow("acquisition", CV_WINDOW_AUTOSIZE );
    namedWindow("binaire", CV_WINDOW_AUTOSIZE );
    namedWindow("dne", CV_WINDOW_AUTOSIZE );
    namedWindow("cont", CV_WINDOW_AUTOSIZE );

//**Ouverture de la video
    printf("Ouverture video\n");
    avi = cvCaptureFromFile("G:\\Anthias\\Output16_boncontraste_bonneglisse_toAVI.avi");

    if (!avi)
    { 
        printf("Video non ouverte");
        return -1;}

//**Recuperation de la dernière image de la video
    while(cvGrabFrame(avi))
        im = cvQueryFrame(avi);

    cvShowImage("acquisition",im);
    cvSaveImage("image.jpg",im);

//**Traitement de l'image   

//**Récupération de l'image en tant que Mat
    printf("Traitement image\n");                                               
    printf("ouverture de l'image...");
    immat = imread( "G:/Anthias/OpenCV/Essais/essais/essais/image.jpg", 1 );

    if (immat.empty())
    { 
        printf("Image non ouverte\n");
        cvWaitKey();
        return -2;}
    else {printf("Image ouverte\n");}

    imshow("binaire",immat);
    cvWaitKey();

Everything works, until imread, it crashes and I've an error message :

Unhandled exception at 0x7854fdf1 (msvcr90d.dll) in essais.exe: 0xC0000005: Access
 violation reading location 0xCCCCCCCC.

I've seen a question where someone had the same error, but his solution is not mine,

The problem was in environmental variable path, there was for version vs2008 and next for 2012.

I'm using opencv 2.4.1 with Visual Studio 2008, and I've nothing concerning the 2012 version in my path so... IDK xD

I suppose there is something wrong in my environment or whatever, but I can't figure out what it is, and I'm searching for sooo long now ... Please help me ! =) xD

If you need some more infos, just tell me and I'll edit ;)

Thanks all =)

EDIT 1 :

// essais.cpp : définit le point d'entrée pour l'application console.

#include "stdafx.h"
////////////////////////
//**Premiers essais**//
///////////////////////

#include "opencv2/opencv.hpp"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <opencv2 core="" core.hpp="">

using namespace cv;
using namespace std;


int main(int argc, char** argv)
{

//**Variables
    printf("Initialisation variables\n");
    VideoCapture avi;
    Mat im, immat; 
    Mat imde, imcanny, imthresh;
    char* trackbar_value = "Valeur";    
    cvNamedWindow("acquisition", CV_WINDOW_AUTOSIZE );
    namedWindow("binaire", CV_WINDOW_AUTOSIZE );
    namedWindow("dne", CV_WINDOW_AUTOSIZE );
    namedWindow("cont", CV_WINDOW_AUTOSIZE );

//**Ouverture de la video
    printf("Ouverture video\n");
    avi = VideoCapture("G:/Anthias/Output16_boncontraste_bonneglisse_toAVI.avi");

    if (!avi.isOpened())
    { 
        printf("Video non ouverte");
        return -1;}

I've re-write all my code in C++, and now I've got the same kind of error, but with VideoCapture :

Unhandled exception at 0x77c17bec in essais.exe: 0xC0000005: Access
 violation reading location 0xCCCCCCCC.

I think this is why I started to write using C style, and then changed to C++ style because I realised It was better to use C++ for next parts.

What stuff am I mixing ?!

Thanks again =)

EDIT 2 :

  • My processor is "x86..." so have a 32 bit system
  • I use openCV 2.4.1 with Visual Studio 2008
  • I've added core241.lib , highgui241.lib and imgproc241.lib (from x86\vc9\lib file)

All those includes are useful for the next parts of my code, I'll try to create a new project with only the necessary for just opening a video file and see what it does. I'll then comment.

=)