Mukund
11-27-2010, 05:06 PM
Hello,
i needed a suggestion regarding the method im using to flip an image:
i am getting live feed from a webcam. (im continuosly obtaining frames from the webcam using OpenCV)
Now, im drawing these frames onto a glut window. The frame im obtaining from OpenCV is flipped, so i wrote this:
image_data[] has the raw pixel information. This is later used in glDrawPixels() to draw the frame.
/* 640x480 image */
for (unsigned int i = 0, j = (640 * 480 * 3) - 1; i <= j; i++, j--) {
unsigned char temp = image_data[i];
image_data[i] = image_data[j];
image_data[j] = temp;
}
Now, this happens many times in a second. Is this the right way to do it? i mean isn't it very expensive in terms of computation?
Any suggestions would be really helpful.
Thanks.
i needed a suggestion regarding the method im using to flip an image:
i am getting live feed from a webcam. (im continuosly obtaining frames from the webcam using OpenCV)
Now, im drawing these frames onto a glut window. The frame im obtaining from OpenCV is flipped, so i wrote this:
image_data[] has the raw pixel information. This is later used in glDrawPixels() to draw the frame.
/* 640x480 image */
for (unsigned int i = 0, j = (640 * 480 * 3) - 1; i <= j; i++, j--) {
unsigned char temp = image_data[i];
image_data[i] = image_data[j];
image_data[j] = temp;
}
Now, this happens many times in a second. Is this the right way to do it? i mean isn't it very expensive in terms of computation?
Any suggestions would be really helpful.
Thanks.