Segmentation fault using OpenCV

c++

Solution

In the lines:

vector<Mat> images;

and

images[i-1] = imread("ImageData/"+m_object_type+"/"+m_object_type+"-"+buffer+".jpeg", 1);

You have declared vector `images` but its size is still unspecified. Therefore you can not assign its elements according to indices. Instead, you can `push_back` new `Mat` elements:

images.push_back(imread("ImageData/"+m_object_type+"/"+m_object_type+"-"+buffer+".jpeg", 1));

Or, you can initialize vector `images` with a size of `m_number_of_images` :

vector<Mat> images(m_number_of_images);

Problem

i am currently writing my first C++ program and so far, even if it's not complete, i wanted to try some test runs, after dealing with all compiler errors. I'll provide most of the code in the following links: http://pastie.org/8196032 http://pastie.org/8196025 Since i'm just allowed to post 2 links the header for ImageComparison is missing, which is not very important i think. stdafx.h includes required opencv and std libs. I ran gdb and got this result: ``` Program received signal SIGSEGV, Segmentation fault. 0x000000000040655c in cv::Mat::release() () (gdb) bt >#0 0x000000000040655c in cv::Mat::release() () >#1 0x0000000000406410 in cv::Mat::operator=(cv::Mat const&) () >#2 0x00000000004052ed in ImageComparison::LoadImages() () >#3 0x000000000040518e in ImageComparison::DoImCo() () #4 0x0000000000405019 in main () ``` Which doesn't give me any clue what's wrong here. I apologize if my question is just to dump, but i appreciate any suggestions.

Original source