Hello,
I'm working on a webcamera video stream processing program, and I'm having some trouble with the internals of actually just modifying the stream.
My main issue is that the only webcam I have uses a compressed IYUV format - which ends up being something like 12 bits per pixel.
Here is the code I was told to use to decompress that:
//the Frame Callback function set with capSetOnFrameCallback (or something like that)
LRESULT CALLBACK Edge_Processor(HWND hwnd, LPVIDEOHDR lpVHdr)
{
if(!lpVHdr->lpData) //Note that "lpData" is the actual frame data - whether it's compressed or decompressed.
return 0;
BITMAPINFO frameinfo;
capGetVideoFormat(hwnd, &frameinfo, sizeof(frameinfo));
//Find the appropriate decompressor for this frame... of course this doesn't need to be done every frame.
if(!theApp.dlg->decompress
or){ //declared as "HIC decompressor"
ICINFO icinfo;
//thank you CodeGuru Guy!
//walk over all codecs, find desired
for (int i=0; ICInfo(ICTYPE_VIDEO, i, &icinfo); i++)
{
theApp.dlg->decompressor=I
CLocate(ic
info.fccTy
pe, icinfo.fccHandler, &frameinfo.bmiHeader,
NULL, ICMODE_FASTDECOMPRESS);
if (theApp.dlg->decompressor)
{
theApp.dlg->decomp_handler
=icinfo.fc
cHandler; //declared as "DWORD decomp_handler".. this is a function pointer.
break;
}
}
}
//THIS RETURNS A VALID DIB HANDLE... however I have no idea how big it is.... but hopefully it decompressed it to 24-bit, in the dimensions of the camera.
HANDLE dib_to_process=ICImageDeco
mpress(the
App.dlg->d
ecompresso
r, 0, &frameinfo, lpVHdr->lpData, NULL);
.... ok ... that's pretty much what I got as far as translating the stream goes.
However - I do not know how to edit that DIB. I've tried just modifying the input version outright (I have another capture device that supports RGB 24 (uncompressed)), that doesn't exactly work either.
Someone please help me with this. I need to access pixels in the video.
Also I would like a tip to make this a little faster. Going in and processing every pixel in the captured image proves to be slow - just because of the processing I'm doing. I noticed that in the VIDEOHDR struct, it has variables like "bytes used", and "seconds captured" - or something like that. I was hoping to find out how I can process a smaller portion of the video capture so that this function runs faster.
I know that's asking alot - but I'm going to offer a good point value for this. Please offer good explanations...
Start Free Trial