I am getting the following error while executing the code stated below. I have linked the libraries properly and the code builds fine. my code is stated below:
int main(int argc, char** argv)
{
Mat img, frame, result, mask, converted;
int region_size = 12;
int ruler = 10;
int min_element_size = 50;
int num_iterations = 10;
if (argc == 1) {
cout << "Usage: " << argv[0] << " image.jpg" << endl;
return -1;
}
else {
cout << "the image you are processing: " << argv[1] << endl;
img = imread(argv[1]);
if (img.empty()) {
cout << "Error loading the image" << endl;
return -1;
}
}
/*img= imread("image.jpg", IMREAD_COLOR);*/
imshow("Input", img);
img.copyTo(frame);
cvtColor(frame, converted, COLOR_BGR2HSV);
Ptr<SuperpixelSLIC> slic = createSuperpixelSLIC(converted, MSLIC, region_size, float(ruler));
slic->iterate(num_iterations);
slic->enforceLabelConnectivity(min_element_size);
cout <<"There are Total"<< slic->getNumberOfSuperpixels() << " superpixels" << endl;
// get the contours for displaying
slic->getLabelContourMask(mask, true);
result.setTo(Scalar(0, 0, 255), mask);
// display output
//superpixel contours
imshow("superpixel contours", result);
imshow("Mask", mask);
Mat labels;
slic->getLabels(labels);
const int num_label_bits = 2;
labels &= (1 << num_label_bits) - 1;
labels *= 1 << (16 - num_label_bits);
imshow("Labels", labels);
waitKey(0);
}
while executing the code i get the following error:
0xC0000005: Access violation reading location 0x00000000.
User contributions licensed under CC BY-SA 3.0