<< Chapter < Page | Chapter >> Page > |
Now have a look at the main.c file and take note of the memory spaces used. The internal memory is of size 12 * 640. This single memory space is going to be used to store both the input lines from the camera image and also the results of the color conversion, thus explaining its large size. Basically the internal memory is partitioned by us for different buffers. The output data buffer needs only 4*640 bytes thus it's space starts at
int_mem + (8 * cols); //cols = 640
and ends at 12*cols – which gives us 4*cols of space. Though it is useful to partition internal memory in such a way, it is recommended not to. It is very easy to mess up the other data too, so simple, so our solution would have been to create a separate memory space of size 4*cols.
The external memory, though declared here, will not be used in the program, however you may need to allocate some external memory for this project lab assignment.
Good examples of the external memory use are the input buffer (captured image) and output buffer (to be placed onto the screen). There are a few steps in obtaining these buffers:
VDIS_open();
VCAP_open();
color(VCAP_NTSC, VDIS_640X480X16, numFrames);
This specifies:
VDIS_config(displayMode);
VCAP_config(captureMode);
for (frameCnt=0; frameCnt<numFrames; frameCnt++)
This loop iterates for a set number of frames and processes them one at a time. And the lines following this :
input = VCAP_getFrame(SYS_FOREVER);
output = (Uint16*)VDIS_toggleBuffs(0);
are used to obtain the capture and output frames. After this statement, ‘input’ will hold a pointer to external memory where the captured frame is stored. The ‘input’ pointer holds pointers ‘y1’, ‘c1’ etc to the different color component of the image. These color components are in external memory as well.
And ‘output’ will hold a pointer to a buffer in external memory, to which we will write whatever we need to output to the screen. Basically the buffer is the size of the output frame (640 X 480 X 2 bytes/pixel), and we can write what we wish to it. And, the next time togglebufs(0) is called, everything we placed in that buffer will be put on the screen. And a new buffer will be allocated, the pointer ‘output’ will be updated and we can now write to the next frame.The next line
out_image.img_data = (unsigned char *) output;
updates the pointers we had setup.
We then move on to the color_convert(..) routine. We pass the memory pointers we had created so that our color_conv program can process the input frame we obtained.In color_conv, we begin by setting up streams to bring in data and streams to send out data. After that we begin the color-space conversion.Notification Switch
Would you like to follow the 'Digital signal processing laboratory (ece 420)' conversation and receive update notifications?