Elaborate on video acquisition on Microsoft Windows

What’s video

 

Video is the technology of electronically capturing, recording, processing, storing, transmitting, and reconstructing a sequence of still images representing scenes in motion. Video technology was first developed for television systems, but has been further developed in many formats to allow for consumer video recording. Video can also be viewed through the Internet as video clips or streaming media clips on computer monitors.

--from http://en.wikipedia.org/wiki/Video

 

It seems to me video is a container of still pictures. The container itself defined How fast the picture exchanged (Frame Rate, number of still pictures per second), what’s the pictures format (How the pictures compressed), how the video itself compressed….

 

Get video from video acquisition device in Microsoft Windows

 

Before you start the acquisition action, you may setup the format of the video (maybe say the format of still picture is more understandable). Say, first of all, get the current format which is used by the device(if you are not familiar with these serial capXXX, refer my article: Video Capture and play):

capGetVideoFormat( hwnd,  psVideoFormat, wSize );

Then Setup to a new format using:

capSetVideoFormat( hwnd,  psVideoFormat, wSize );

Here psVideoFormat is a pointer to The BITMAPINFO. BITMAPINFO structure defines the dimensions and color information for a DIB(Device Independent Bitmap, Know as BMP).

After you start the capture of the video, you can get the single picture data in the callback funtion:

LRESULT CALLBACK capVideoStreamCallback (HWND hWnd, LPVIDEOHDR lpVHdr)

{

     // lpVHdr->lpData contains the still picture data( DIB );

     // you can create a bitmap file using this data block, or collecting the every data block to form a video file, or draw it on a window.

     // here I only draw it on a window DC using a windows API DrawDibDraw.

     ::DrawDibDraw(hDib,

                                     hdc,

                                     0,                       // left pos

                                     0,                       // top pos

                                     -1, -1,               // don't zoom x,y

                                     bmpinfo->bmiHeader,  // bmp header info

                                  lpVHdr->lpData,            // bmp data

                                     0, 0,   WIDTH, HEIGHT,

                                    DDF_SAME_DRAW);

// you can also compressed it then send it to a host

// data  = Compress(lpVHdr->lpData, length)

// sendto(data);

 

    return TRUE;

}

 

Have funJ

 
發佈了43 篇原創文章 · 獲贊 1 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章