Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Strange bug in opencv

I am getting a very strange Segmentation fault error in my project and after 1 full day of my debugging, I have narrowed it down to this part. Below sample code is giving me error at when accessing pixel value at row higher than 476 but it should work till 479, given height of matrix is 480. My opencv version is 3.4.1 and using this on Mac OS 10.13.3

#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <chrono>
#include <thread>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
  Mat image = Mat::zeros(480,640,CV_8UC1);

  while (true){
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    cout << image.at<int>(477,638)<< endl; // Error is HERE
  }

  return 0;
}