VCAPG2 for MATLAB
Summary:
VCAPG2 is DirectShow based video capture DLL that support various
types of video capture cards.
Keywords:
vcapg,usb,frame,grabber,IEEE1394,Vfw,directshow,video
Screenshot of two camera grabbing images under MATLAB.
One camera is connected to Omni-directional camera, the other is
normal camera.
you can see preview screen at left side of window. The bottom of
left side of short menu describes video mode short menu. Depending on video
capture device you may change following video mode.
TV Tuner |
Second Crossbar |
Video Crossbar |
Video Capture Pin |
Video Capture Filter |
Video Source |
Video Display |
Video Format |
Description:
VCAPG2 is a new version of MATLAB resident video capture program,
which employs Microsoft's DirectShow libraries rather than the older Video for
Windows (VfW) library.
In order to run VCAPG2, you will need to install the DirectX
runtime libraries.
The vcapg2 requires a video capture device, such as a USB camera
to be installed and working properly.
This code has been developed and tested with DirectX 8.1 and 9.0 with
MATLAB6.1/6.5.
Features are
1. Up to 6 video capture cards can grab images at one command.(I
tested one and two video capture cards)
2. Supported video capture devices are including IEEE1394 based DV
CAM, USB Camera as well as old VFW based Camera.(I tested DV-CAM, USB Camera,
VFW based Camera)
3. VCAPG2 can run up to almost twice as fast as VfW based program
such as VCAPG [1] which is available both source and binary code from http://www.ikko.k.hosei.ac.jp/~matlab/matkatuyo/
that I published.
Plaforms:
2000/XP
(NOTE: 95/98/ME are not supported!! Please use vcapg)
MATLAB Version:
6.1
or later
How to Install:(2003/03/07)
Just copy vcapg2.dll to your MATLAB current directory.
(You can check MATLAB current directory by usiing 'pwd' command.)
After that you just type 'vcapg2' will appear preview window.
Notes:
Supported default capture color mode only RGB 16bit. However
depending on video capture card, you may change different color modes by clicking
task tray icon.
VCAPG2 is a MATLAB residents
program; you can confirm residents or not left bottom side of task tray icon.
From task tray icon, you can change video mode and crossbar and/or TV tuner
mode, which are depending on installed video capture cards.
If you want to remove VCAPG2 from MATLAB, type clear all.
Sample scripts:
%%%%%%%%% %sample script for One video capture card is installed. %Initialization mode clear all; cardnum=vcapg2; % you will get available video capture devices
number usually 1 % capture mode aa=vcapg2;% grabbing camera image. imshow(aa); clear all; % remove |
%%%%%%%%% %sample script for Two camera capture cards are installed clear all; %Initialization mode cardnum=vcapg2; % you will get available video capture devices
number usually 2 % capture mode [aa,bb]=vcapg2;% grabbing camera image. subplot(1,2,1);imshow(aa);subplot(1,2,2);imshow(bb); |
%%%%%%%%% %sample script for Two camera capture cards are installed % if you have two video capture card, you can choose video card
at initialization mode clear all; cardnum=vcapg2(1); % you can set 0 or 1 % capture mode aa=vcapg2;% grabbing camera image. imshow(aa); |
%%%%%%%%% %sample script for One video capture card is installed. % realtime image processing example just process diff at Red
image %Initialization mode clear all; cardnum=vcapg2; % you will get available video capture devices
number usually 1 close all;figure(1);set(1,'doublebuffer','on'); % capture mode for i=1:100 aa=vcapg2;% grabbing camera image. subplot(2,1,1);imshow(aa);subplot(2,1,2);imshow(diff(double(aa(:,:,1)),[]); drawnow;% this is important to view realtime. end clear all; % remove |
Difference between VCAPG and VCAPG2:
|
VCAPG |
VCAPG‚Q |
Library |
Video For Windows API |
COM based DirectShow
library |
Multiple camera support |
not available due to
specification of VfW |
Up to 6 cameras. we test up to 2 cameras. |
Type of frame grabbing device |
VfW |
DirectShow,VfW including (IEEE1394 DvCam, USB Camera) |
Captured color mode |
Depending on frame grabber 1,4,8,16,24,32bitRGB is
supported |
Depending on frame grabber default color mode is
16BitRGB. |
Speed of grabbing images (Depending on hardware and
color mode) |
About 23sec/100 frame |
About 15 sec / 100 frame |
Supported OS |
95/98/ME/2000/XP |
2000/XP |
By using GraphEdit (which is
bundled with DirectX SDK), you can see connection of video capture cards.
This is example of DV-camera
preview screen and GraphEdit view.
If you want to change DV
resolution or quality, you can do from GraphEdit property like following.
Update Information:(2003/02/07)
Preview window
setting can change at initialization time.
Difference from
previous version is initialization option. Default preview interval set to 300msec.
Usage: Only works under initialization time vcapg2(Board Num,Preview interval) Board
Num: 0,1,2,3 ,[ ] means default mode
Preview inerval: 1 to 65536[mSec],0 means no preview image mode |
Usage examples:
clear
vcapg2;vcapg2([ ],0); % multiple camera image grabbing mode with no preview
window
clear vcapg2;vcapg2([
],300); % multiple camera image grabbing mode with preview window at 300 mSec refresh
rate.
Also you can specify
video capture device number if available.
clear vcapg2;vcapg2(0,0); % board No. 0 camera image grabbing
mode with no preview image
clear vcapg2;vcapg2(1,100); % board No. 1 camera image grabbing
mode with preview window at 100mSec refresh rate.
Both Binary code and Source code is available from here:(2007/08/01)
Binary DLL can be available from
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=2939&objectType=file
Trouble shooting:(2003/03/07)
I made this utility based on amcap.cpp.
Please check by using amcap.exe, which is bundled with DirectX
SDK.
If you have experienced similar problem, problem may be due to
windows or capture driver.
You may be better to reinstall windows or capture driver.
Multiple-camera problem:(2003/03/07)
In order to work multiple-camera mode, DirectShow based video
capture drivers are required.
1. The vcapg2 cannot handle the combination of several VfW based
video capture board, since VfW based driver did not support multiple camera
mode.
2. Some USB based video capture driver cannot work more than two
cards, because of limitation of the USB bandwidth.
3. Please check by using GraphEdit to see the schematic diagram of
video capture block. If you cannot see video capture block, probably the video capture
driver didnft support Directshow.
Video resolution problem:(2003/03/07)
1. Several VfW based video board cannot change the resolution from
vcapg2, please change the default resolution by using video board bundled
software or amcap before starting vcapg2.
2. In order to change resolution of IEEE1394 based camera resolution;
please use to change GraphEdit, which is bundled with DirectX SDK.
3. Please check by using vcapg, which is available in http://www.ikko.k.hosei.ac.jp/~matlab/matkatuyo/.
Rights to use, citation:
Author may encourage to maintenance and consuming time to develop
this utility, please cite the following reference in your paper or academic research.
Kazuyuki Kobayashi,"MATLAB Utilization Book", Shuwa
System Co, Ltd., 2001,ISBN 4-7980-0141-4
For further update information browse to:
http://www.ikko.k.hosei.ac.jp/~matlab/matkatuyo/vcapg2.htm
References:
[1] Kazuyuki Kobayashi,"MATLAB Utilization Book", Shuwa
System Co, Ltd., 2001,ISBN 4-7980-0141-4 (Japanese)
[2] Michael Linetsky, "Programming Microsoft
Directshow", Wordware,ISBN: 1556228554
[3] DirectX 8.1 SDK amcap.cpp
[4]
http://vision.kuee.kyoto-u.ac.jp/~hiroaki/firewire/directshow.html (Japanese)
[5] http://wwwdoi.elec.nara-k.ac.jp/html/jisyu/dxm/ds10.html
(Japanese)