Hello:
My name is Juan Crespo and I write you from Spain. I am developing a vision application with LabWindows/CVI and I have a problem that I hope you can help me to solve.
I wanted to show two image windows in my application, the first window shows the original image from camera and the second window must show an image that is generated by the use of the "imaqArraytoImage" function, the contents of this array (the array is a 2-D array of RGBValue structures) are calculated, in every frame, using the values of the pixels of the camera image. The size of the camera image are 320 x 240 pixels and the size of the array are 75 x 55 elements.
The problem is as follows: I wished to write my application using dynamic memory allocation (I declare an array "RGBValue **atentor_ppal;"), so in the beggining of the application the size of the array is obtained and the array is dimensioned as follows:
atentor_ppal = (RGBValue **) calloc (numero_vertical, sizeof (RGBValue *));
for (i=0;i atentor_ppal[i] = (RGBValue *) calloc(numero_horizontal, sizeof (RGBValue));
Where "atentor_ppal" is the name of the array, while numero_vertical and numero_ horizontal are the dimensions of the array, previously calculated (with values of 55 and 75, respectively).
After that, I make use of the array for generating the image:
imaqArrayToImage (image2, atentor_ppal, numero_horizontal, numero_vertical);
But, if I make this, when I compile -in debug mode- the project I obtain the following result (NOTE: "atentiorum.c" is the name of tha source file):
FATAL RUN-TIME ERROR
"atentiorum.c", line 231, col 39, thread id 0x00000584
Array argument too small (220 bytes). Argument must contain at least 16500
bytes (4125 elements).
And the error is marked in the code as follows:
imaqArrayToImage (image2, atentor_ppal , numero_horizontal, numero_vertical);
But, if I change the dynamic allocation of memory for a static declaration of the array (RGBValue atentor_ppal[55][75] instead of RGBValue **atentor_ppal and posterior use of "calloc") I have no problem.
I have checked, by using breakpoints and "view variable value", that, in the first case, in the moment of the memory reserve "numero_vertical" and "numero_horizontal" have both their right values.
I dont know what the error cause could be. I would be very grateful to you if you can give some cue that help me.
Thank you very much for your attention.
Best Regards
Juan Crespo