juhara.com

  • Narrow screen resolution
  • Wide screen resolution
  • Decrease font size
  • Default font size
  • Increase font size
Home Articles Multimedia Programming Programming DirectShow to capture video from camera
Programming DirectShow to capture video from camera PDF Print E-mail
Written by Zamrony P. Juhara   
Friday, 13 November 2009 15:09
Article Index
Programming DirectShow to capture video from camera
Video Capture Implementation with Delphi
All Pages

Price of PC camera is getting lower, affordable by everybody. From cheap camera, suitable for simple video conferencing in messaging tool such as Yahoo Messengger or IM, to expensive and sophisticated ones for recording high quality video. Even, current notebooks are equipped with built-in camera.

Now I will take you to program the camera and how to integrate it into software application. Of course with DirectShow and Delphi. In this article, I use Turbo Delphi Explorer 2006. I change unit header to the DirectX 9.0 header written by Alexey Barkovoy.

Application demo, which we are going to build, is still making use of uDirectShowPlayer.pas unit which contains implementation of TBasicPlayer class, just like previous DirectShow article series. Because this unit previously using DirectX 8.0 header unit written by Project JEDI team, We need to make some minor change due to naming differences on some data types.

You may need to read Multimedia Player with DirectShow part 1 and Multimedia Player with DirectShow part 2 before continue reading this article, because I will not explain basic steps to get started with DirectShow.

Video Capture in DirectShow

In DirectShow, video capture refer to process of recording with video input device such as camera, TV tuner, video tape recorder etc. Camera manufacturer usually already ships filter for capturing input from video camera. You can find video capture filters in CLSID_VideoInputDeviceCategory category. There is good chance that there is one filter in this category when you have one video input device, but it may be more if you have more video input devices installed in your system. What you need to do is enumerating to get instance of video input device filter.

Before we dive in camera programming, it is better if you try it first with GraphEdit utility shipped along with DirectX SDK. In GraphEdit, add filter by clicking Graph->Insert filters. You will face dialog as in Figure 1. Click and expand Video Capture Sources and pick one of video input filter you want. Click Insert filter button.

gambar-1-insert-video-capture-dialog

Figure 1. Insert video capture filter dialog.

Next, add Video Renderer filter inside DirectShow Filters category. Connect output pin of video input filter with input pin of video renderer filter. If succeed, you will get something like in Figure 2. Your system may be a little bit different. Try to run filter graph by clicking Run button (green triangle button).

gambar-2-filter-graph-aplikasi-web-camera

Figure 2. Filter graph of video capture application.



Last Updated on Friday, 13 November 2009 15:54
 

Language

IndonesianEnglish (United Kingdom)

Game Institute
DAZ3D

Is this article helpful? Help this site improve by donating. Any amount is appreciated.