Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - morrisb

Pages: [1]
1
Graphics / RGBA to BGR
« on: February 17, 2011, 05:27:50 pm »
I'm just using direcshow capture and spitting pointers to the video data out to opengl for display.

This seems to work fine as far as display goes.  With a fast machine I can display 2 1920x1080 video inputs with very little problem. My real enemy is latency, but initial tests seem to suggest it's generally under 10ms and so far has been no more than one frame.  As I refine the code I expect it to actually go up because I'm not doing much error checking right now.  Howver, as long as it stays below 30ms I should be fine.

I plan to look at the ffmpeg library, especially when I get to a port to linux, but my only experience with it so far was using a java wrapper for it on a project a couple years ago.

As far as the RGBA conversion goes, this would only be for capturing frames as a "still store", so the time isn't too big a deal if I do it in a thread.

If you have some suggestions on how ffmpeg might be used here, I'd love to get more details.

thanks,

morris

2
Graphics / RGBA to BGR
« on: February 17, 2011, 04:03:12 pm »
I did a test on the time it takes to do this on a laptop that's about 3 years old - Core-2 (not core-2 duo) processor with 3 gig of ram and winXP and also on a desktop machine with a core i7 950, 3.2 gHz, 6 gig ram and win7 64bit.

With a 1024x768 image (actually just random data) the laptop took about 28ms to do the conversion from BGR to RGBA.  The desktop took about 6ms.

I've included the code I used below.  Comments are welcome.

Code: [Select]


void testConversion()
{

__int64 freqx, tStartx, tStopx;
unsigned long TimeDiffx;
unsigned long microsec;

// Get the frequency of the hi-res timer
QueryPerformanceFrequency((LARGE_INTEGER*)&freqx);

int w = 1024;
int h = 768;
int d = 3;  // rgb bit depth
int da = 4; // rgba bit depth

// this makes a 3 bit depth "image" of static
unsigned char* old_image = makeARandomByteArray(w, h, d);

//QueryPerformanceCounter((LARGE_INTEGER*)&tStartx);

int old_size = w * h * d;
int new_size = w * h * da;

//unsigned char r = 0;
//unsigned char g = 0;
//unsigned char b = 0;
unsigned char a = 255;

long counter = 0;

//QueryPerformanceCounter((LARGE_INTEGER*)&tStartx);
// this takes about 3 ms on my laptop
unsigned char *new_image = new unsigned char[new_size];

QueryPerformanceCounter((LARGE_INTEGER*)&tStartx);

// this loop takes about 31 ms on my laptop
// after dropping the assignment to r,g,b this dropped to 28 ms
        // on an i7 3.2 gHz 64bit Win7 machine this took 6 ms
for (int i = 0; i < old_size; i+=3)
{
//b = old_image[i];
//g = old_image[i + 1];
//r = old_image[i + 2];

// I saved about 3 ms (around 10% of total time) by not assigning to variable r, g & b (above)

new_image[counter] = old_image[i + 2]; // r
new_image[counter + 1] = old_image[i + 1]; // g
new_image[counter + 2] = old_image[i]; // b
new_image[counter + 3] = a;
counter += 4;
}

QueryPerformanceCounter((LARGE_INTEGER*)&tStopx);
microsec = (unsigned long)(((tStopx - tStartx) * 1000000) / freqx);
cout << "Conversion took " << microsec << " microseconds" << endl;

}


3
Graphics / RGBA to BGR
« on: February 16, 2011, 08:36:06 pm »
I guess that's why they call it manual ;)

thanks again

4
Graphics / RGBA to BGR
« on: February 16, 2011, 08:26:04 pm »
Thanks Laurent.

Is there a better way than just making a new, larger, array and copying in 3 bytes in the new RGB order and then poking a 255 into the fourth spot with a for next loop?

morris

5
Graphics / RGBA to BGR
« on: February 16, 2011, 04:12:59 pm »
I have some large textures (1920x1080) that are currently using BGR from video capture devices.  Rather than create new textures when I want to display a still image, I was hoping to re-use these textures in a similar way to how I'm doing it now with continuously updating video data, using glTexSubImage2D.

If I load an image from file using sfml, I'll have an RGBA set of pixel data as I understand it.  Can I simply change the glTexSubImage2D data type from BGR to RGBA and pass in the data pointer, or will there be a problem since the texture is currently using a different image data type?

On a related note, I know that I can do a screen grab directly using sfml, but there may be times when I want to grab an image from a video stream that is not being displayed on screen.  This data will be in BGR format as I mentioned above.  How would you suggest getting that to a format that can be saved using LoadFromPixels (or LoadFromMemory if that makes more sense)?

I should note that I'm still using glut for the opengl portions of the code.  I've only recently come across (the outstanding) SFML library and am slowly integrating it into the project.  Sorry if this confuses matters, it's a work in progress.

thanks,

morris

6
Graphics / fullscreen on second monitor
« on: February 15, 2011, 01:17:21 pm »
Thanks for all the info.  I really appreciate your help.

morris

7
Graphics / fullscreen on second monitor
« on: February 15, 2011, 12:34:40 am »
The resolution is very tightly controlled for my project, so it should work out fine.

One more question though, and this is probably a platform thing, but as far as rendering goes, is there any difference between a "fullscreen" window and a "fake" fullscreen window?  In other words is there any change in the acceleration or timing (vertical sync is a must for me) of the 3d being displayed?

morris

8
Graphics / fullscreen on second monitor
« on: February 14, 2011, 09:47:36 pm »
Another thought, can I create an "undecorated" window with sfml?  Then I can just put it at the correct coordinates for the second monitor and size it to the full resolution.

thanks,

morris

9
Graphics / fullscreen on second monitor
« on: February 14, 2011, 09:14:25 pm »
Oh well....

Any ideas how that might be done as a work around, or even going outside sfml and creating a window to render in to?  Also, is this a windows thing, or an sfml design thing and is it a permanent design thing?

thanks,

morris

10
Graphics / fullscreen on second monitor
« on: February 14, 2011, 08:06:23 pm »
Fullscreen seems to work fine for me on my primary monitor, but I haven't been able to figure out how to open a fullscreen window on a second (or third or fourth) monitor.  I'm using windows 7, both 32 and 64 bit on separate machines and using VS 2010 as my IDE.

thanks,

morris

Pages: [1]
anything