Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Pointer to Mat Variables

Hello, I want to add a dynamic array of Mat variebles, i.e. a 2D array of images. Simply suppose you are putting e.g. 3 rows and 4 columns of your images on the table. I write the following code: Mat *img_array; Mat temp = imread("Lena.tif", CV_LOAD_IMAGE_ANYDEPTH); img_array = (Mat *)malloc(hor * sizeof(temp)); for (char i1 = 0;i1<hor;i1++) {="" img_array[i1]="(Mat" *)malloc(ver="" *="" sizeof(temp));="" }="" puts("initializing="" image="" array...");="" for="" (i1="0;" i1="" &lt;="" hor;="" i1++)="" for="" (char="" j1="0;" j1="" &lt;="" ver;="" j1++)="" img_array[i1][j1]="Mat::zeros(rows," col,="" cv_8uc3);="" hor,="" ver="" are="" the="" nuber="" of="" horizontal="" and="" vertical="" elements="" of="" each="" array="" and="" rows,="" col="" refer="" to="" the="" number="" of="" the="" pixels="" of="" each="" individual="" image.="" when="" i="" run="" the="" program,="" the="" following="" error="" is="" issued:="" exception="" thrown="" at="" 0x00007ffcffa28bcc="" (opencv_world320d.dll)="" in="" consoleapplication1.exe:="" 0xc0000005:="" access="" violation="" reading="" location="" 0xffffffffffffffff.="" occurred="" any="" idea?<="" p="">

click to hide/show revision 2
None

updated 2017-10-13 05:41:09 -0600

berak gravatar image

Pointer to Mat Variables

Hello, I want to add a dynamic array of Mat variebles, i.e. a 2D array of images. Simply suppose you are putting e.g. 3 rows and 4 columns of your images on the table. I write the following code: code:

Mat *img_array;
**img_array;
Mat temp = imread("Lena.tif", CV_LOAD_IMAGE_ANYDEPTH);
img_array = (Mat *)malloc(hor **)malloc(hor * sizeof(temp));
for (char i1 = 0;i1<hor;i1++) {="" img_array[i1]="(Mat" *)malloc(ver="" *="" sizeof(temp));="" }="" puts("initializing="" image="" array...");="" for="" (i1="0;" i1="" &lt;="" hor;="" i1++)="" for="" (char="" j1="0;" j1="" &lt;="" ver;="" j1++)="" img_array[i1][j1]="Mat::zeros(rows," col,="" cv_8uc3);="" hor,="" ver="" are="" the="" nuber="" of="" horizontal="" and="" vertical="" elements="" of="" each="" array="" and="" rows,="" col="" refer="" to="" the="" number="" of="" the="" pixels="" of="" each="" individual="" image.="" when="" i="" run="" the="" program,="" the="" following="" error="" is="" issued:="" exception="" thrown="" at="" 0x00007ffcffa28bcc="" (opencv_world320d.dll)="" in="" consoleapplication1.exe:="" 0xc0000005:="" access="" violation="" reading="" location="" 0xffffffffffffffff.="" occurred="" any="" idea?<="" p="">
0;i1<hor;i1++)
{
    img_array[i1] = (Mat *)malloc(ver * sizeof(temp));
}
puts("Initializing Image Array...");
for (i1 = 0; i1 < hor; i1++)
    for (char j1 = 0; j1 < ver; j1++)
        img_array[i1][j1] = Mat::zeros(rows, col, CV_8UC3);

hor, ver are the nuber of horizontal and vertical elements of each array and rows, col refer to the number of the pixels of each individual image. When I run the program, the following error is issued: Exception thrown at 0x00007FFCFFA28BCC (opencv_world320d.dll) in ConsoleApplication1.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF. occurred Any Idea?