I’d got curious and did a test to see how RGBSurface compares to OpenGL. Results from a compiled app on an old mac…
process 30 MemoryBlocks containing 720x404 RGB data
seconds
scan RGB to pic time: 0.733314 41 per sec
move RGB to OpenGL time: 0.011278 2600 per sec **
scan RGB to pic time (+draw): 1.487114 20 fps
move RGB to OpenGL time (+draw): 0.483332 60 fps
‘Scan RGB’ is the RGBSurface.Pixel technique (all pragmas on) and ‘Move RGB’ is a single OpenGL call. The first two are just times to process, no drawing. The last two measure actual drawing rate. **2600 is too high, I’m guessing the data isn’t processed until drawn.
Letting the memoryblocks loop for awhile Activity Monitor plateaus around…
scan to pic and draw: 75% cpu
load OpenGL and draw: 9% cpu
Playing the source movie in quicktime player is 6% cpu
To test bmp I prebuilt the 30 Memoryblocks with a header and BGRA data, ie a bmp file so it’s basically timing Picture.FromData and Graphics.DrawPicture.
bmp fromData time: 0.420370 71 per sec
bmp fromData time (+draw): 1.001263 30 fps
bmp fromData and draw: 75% cpu
Here’s the testing app if you want to compare on your system. Very very messy. Only the enabled buttons on MainWindow are expected to work.
https://drive.google.com/file/d/0B97iUmOCTUYdQnk3WjF0LVNoT1k/view?usp=sharing 40.6Mb
First put the folders ‘memfiles’ and ‘bmpfiles’ on your desktop. Run and click ‘load all mems’ and ‘load bmp mem’ which load the files to a Memoryblock array. Also click ‘test texture’ which initializes the OpenGL texture for receiving data.
Now it’s primed to run timing tests by clicking on ‘pic play’ for RGBSurface, ‘bmp play’ for FromData and ‘tex play’ for OpenGL. There’s a Checkbox slapped on there labeled ‘+draw’. Toggle that to include drawing in the test or not.
To do a cpu % test requires going through the testing buttons (pic play, bmp play, tex play) and uncommenting the “for pass = 1 to 20” loops. Then it’ll run long enough to level out a cpu load.
So that’s just messy tests, what you might be more interested in is an OpenGLSurface subclass for displaying RGB memoryblocks. RawRGBView wraps up the little bit of the ezgl framework used in testing into a single stand alone control. Simply drop a RawRGBView on your window and initialize the image size
RawRGBView1.texSetSize(720, 404)
as memoryblocks come in pass them to the view
RawRGBView1.texLoadData(rgbDataMemoryBlock)
It’s at proof-of-concept right now, some little things still need tweaking. To run the demo the ‘memfiles’ folder needs to be on the desktop.
https://drive.google.com/file/d/0B97iUmOCTUYdTXN1a1V5QmhUQnM/view?usp=sharing 8k
Hopefully I’ll get to compiling OpenCV in a few days. I played with it once in processing/openFrameworks and had a bewildering time.