Title: VC 6.0??
1Lecture4 ???????
2? ?
- VC 6.0??
- ????
- MIDI
- wav
- ??????
- bmp/YUV
- ?????
- Directshow
3 Visual Studio 6??
- ????????
- ???Visual Studio 2003/2005/2008/2010
4??
5????-MIDI
- MIDI?Musical Instrument Digital
Interface???,??????????????????,???MIDI???????????
?????????,??????????????? - MIDI??????
- MIDI???????(Header Chunk)????(Track Chunk)????
- MThd lt????gt ltHeader??gt //???
- .......
- Mtrk lt????gt ltTrack??gt //???
- .......
-
6- Header Chunk
- char MidiId4
- long length
- int foarmt
- int TrackNum
- int division
- MidiId??MIDI?????,???????MThd
- length?????????(?????????????????),??????6,?format
,TrackNum?division?????????? - format??MIDI???????(0???,1???,2?????)
- division???????,???????(??????0?)
7- Track Chunk
- ?????????????Track Chunk??????MIDI?(?????MIDI?)???
- char TrackChunkId4 //Track Chunk??MTrk
- long TrackChunkMsgLength //?Track Chunk????
- ????????
8????-Wav
- Wav????
- ?????????????????,???RIFF??????
- WAVE???????Chunk??
- RIFF WAVE Chunk, Format Chunk, Fact Chunk(??),
Data Chunk - ??chunk?"???"?"????"?"??"???
9??? ????
ID 4 Bytes 'RIFF'
Size 4 Bytes
Type 4 Bytes 'WAVE'
??? ????
ID 4 Bytes 'fmt '
Size 4 Bytes ???16?18,18????????
FormatTag 2 Bytes ????,???0x0001
Channels 2 Bytes ????,1--???2--???
SamplesPerSec 4 Bytes ????
AvgBytesPerSec 4 Bytes ???????
BlockAlign 2 Bytes ???????(??????????)
BitsPerSample 2 Bytes ???????bit?
2 Bytes ????(??,??Size?????)
10??? ????
ID 4 Bytes fact'
Size 4 Bytes ???4
data 4 Bytes
11??? ????
ID 4 Bytes data'
Size 4 Bytes
data 4 Bytes
??? 8bit?? ??1 ??2 ??3 ??4
??? 8bit?? ??0 ??0 ??0 ??0
??? 8bit?? ??1 ??1 ??2 ??2
??? 8bit?? ??0(?) ??1(?) ??0(?) ??1(?)
??? 16bit?? ??1 ??1 ??2 ??2
??? 16bit?? ??0 (????) ??0 (????) ??0 (????) ??0 (????)
??? 16bit?? ??1 ??1 ??1 ??1
??? 16bit?? ??0(?) (????) ??0(?) (????) ??1(?) (????) ??1 (?) (????)
12???wav/midi???
- Windows?????????????????????Windows MCI(Media
Control Interface) - Visual C?MCI????mciSendCommand()?mciSendString()
??? - DWORD mciSendCommand(UINT wDeviceID,UINT
wMessage,DWORD dwParam1,DWORD dwParam2) - wDeviceID???????ID
- wMessageMCI????
- dwParam1??????
- dwParam2?????????
13- wMessageMCI????
- MCI_OPEN??????
- MCI_CLOSE
- MCI_PLAY??
- MCI_PAUSE??
- MCI_STOP??
- MCI_SEEK??(????/??)
- MCI_RECORD??
- MCI_SAVE??
MCI??????????,??DirectSound??????????WAV???????
14- Matlab?
- wavread()
- wavwrite()
15???????????
- RGB??
- bmp??
- ????
- YUV??
- yuv??
- ????
16?????BITMAPFILEHEADER
?????BITMAPINFOHEADER
???Palette
???????ImageData
17- //14bytes
- typedefstructtagBITMAPFILEHEADER
- WORD bfType
- DWORD bfSize
- WORD bfReserved1
- WORD bfReserved2
- DWORD bfOffBits
- BITMAPFILEHEADER
18- //40bytes
- typedef struct tagBITMAPINFOHEADER
- DWORD biSize
- LONG biWidth
- LONG biHeight
- WORD biPlanes
- WORD biBitCount
- DWORD biCompression
- DWORD biSizeImage
- LONG biXPelsPerMeter
- LONG biYPelsPerMeter
- DWORD biClrUsed
- DWORD biClrImportant
- BITMAPINFOHEADER
19- typedef struct tagRGBQUAD
- BYTE rgbBlue //????????
- BYTE rgbGreen //????????
- BYTE rgbRed //????????
- BYTE rgbReserved //???
- RGBQUAD
???Palette??????????????????24??32??????????
20??Y??
??U??
??V??
????YUVviewer??YUV?RGB??
21fileId fopen(fileName, 'r') subSampleMat 1,
1 1, 1 read Y component buf fread(fileId,
width height, 'uchar') imgYuv(, , 1)
reshape(buf, width, height).' reshape read U
component buf fread(fileId, width / 2 height
/ 2, 'uchar') imgYuv(, , 2)
kron(reshape(buf, width / 2, height / 2).',
subSampleMat) read V component buf
fread(fileId, width / 2 height / 2,
'uchar') imgYuv(, , 3) kron(reshape(buf,
width / 2, height / 2).', subSampleMat)
reshape and upsample convert YUV to RGB imgRgb
reshape(convertYuvToRgb(reshape(imgYuv, height
width, 3)), height, width, 3) fclose(fileId) i
mshow(imgRgb)
22CImg?
- CImg???????C??????,????????????????????,????????
?????? - http//cimg.sourceforge.net/
- ????????????????
23CxImage?
- CxImage?C?????????????????????????
- ?????????????????????????
- ????
- http//www.codeproject.com/KB/graphics/cximage.asp
x
24FreeImage?
- FreeIamge????,??PNG?BMP?JPEG?TIFF???
- ??32bit?windows,?Linux?Mac OS X
- http//freeimage.sourceforge.net/
25DevIL?
- ??????,???????????????????
- ????????,bmp?jpg?pcx?ico?ppm?psd
- http//openil.sourceforge.net/
26PCL?
- PhoXo Core Library (PCL) ??????C????????
- ????,????????/?????????????????
- http//sourceforge.net/projects/pcl/
27ImageStone?
- ???????C?????
- ????/???????????????100??????
- http//www.codeproject.com/KB/graphics/ImageStone.
aspx
28OGRE?
- OGRE(Object-Oriented Graphics Rendering
Engine,???????????)????C?????????????3D??,?????
??????????????????3D????????? - http//www.ogre3d.org
29OpenCV
- OpenCV Intel(c) Open Source Computer Vision
Library,???????????????????C???? - http//www.opencv.org.cn/index.php
- http//sourceforge.net/projects/opencvlibrary/
- ??????
- ???Windows,linux
- ??,??????
- ???
- ????
30- ??OpenCV????????
- cxcore??????(????????????)
- cv????????????(????,????,????,????,????,?????)
- cvaux????????(View Morphing,????,PCA,HMM)
- highgui??????(GUI,????I/O,??????)
31OpenGL
- OpenGL(Open Graphics Library)?????????????????????
???,?????3D????,???????,???????3D???? - ????SGI????????????IRIS GL????????????????????????
,SGI???OpenGL? - http//www.opengl.org
- OpenGL???CAD?????????????????????
32- ????
- OpenGL???(gl)
- OpenGL???(glu)
- ?X?????OpenGL??(glX)
33??????
??DirectShow??????
? ? ?
YUV-gtRGB
???? (mpg/mov)
?????
? ? ?
????
34 DirectShow???????????Windows??????????????,?D
irectX?????????????????????????????DirectShow?????
?????????????????,??????????????????????????????
35DirectShow????
36DirectShow??
- Filter??
- Filter Graph
- ????
- ????
- ????
- ????
- ????
- ?????
37Filter??
Directshow???????,?????????COM????,??Filter?Direct
show???????????????????,?????????????Filter???Dire
ctshow????Filter?????????Pin??,Filter????Pin?????D
irectShow??Filter Grpah???Filter?
38Filter???
- ????(Source Filter)
- ?????(Splitter Filter)
- ?????(Decoder Filter)
- ?????(Renderer Filter)
- ??????????????,????ASF????(ASF Reader
Filter)??????????????????
39????????????????Filter?????AVI?????? 1)
??????????AVI??,??????(??????Filter??) 2)
??AVI???????,????AVI??Filter??????????? 3)
?????,?????????,?????decoder filters ? 4)
??Renderer Filter??????? 5) ???????????,???????
DirectSound DeviceFilter?
40Filter Graph
AVI?????Filter Graph
41Filter Graph??
?DirectShow?,Filter Graph??????IGraphBuilder???,??
??Win32 API??CoCreateInstance()???????Filter
Graph????????????Filter,???????????????????Filter?
??FilterGraph????
421)RenderFile IGraphBuilder?????????FilterGraph????
?????????????IGraphBuilderRenderFile?HRESULT
RenderFile(LPCWSTR lpwstrFile, LPCWSTR
lpwstrPlayList) 2)Render ???????????Pin??,??????
?FilterGraph????????????Filter,???????Render
Filter??? 3)ConnectDriect ?????????Filter????,???
??,????????????????????????Pin???????,????????Filt
er????
434)Connect ???????ConnectDirect??????????????????Fi
lter,???ConnectDirect??????,??????????ConnectDirec
t??????Filter,????????,???????Filter??? 5)AddFilt
er ??????????Filter???Filter Graph?,???????Filter?
???Filter Graph????Filter????? 6) ????Filter
Graph ????Filter Graph???????????????Filter???????
???????????,?????FilterGraph??????????????
44????
RenderFile?Render?Connect??????????????DirectShow?
,?????????????
45????
Filter??????????????DirectShow????????????????????
?????DirectShow?????????????Filter?????,??????????
????????????????????????majortype?subtype?formatt
ype??????????GUID????
46majortype?????????,?????????(MEDIATYPE_Video)???(
MEDIATYPE_Audio)?????(MEDIATYPE_Stream)?? subtype
????majortype,?????????,??majortype???,subtype???
?????UYVY?YUY2?RGB24?RGB32??majortype???,subtype?
???????PCM????AC3???? formattype????????????????
?????,???????????????????????,?????????????????
47????
48????
Filter Graph??????????????????????????????
?????,?????????????????????????,??????????????????
???? ?Filter Graph?????????????????????IGr
aphBuilder???IMediaControl??????????,??????????
IMediaControlRun() IMediaControlPause() IM
ediaControlStop() IMediaControl GetState(
LONG msTimeout, OAFilterState pfs)
49????
????????????????????????????????IMediaSeeki
ng???SetRate????????????????????IMediaSeekingSet
Rate?,Filter Graph Manager??????? 1)??IMediaSeeki
ngGetCurrentPosition???????? 2)????Filter
Graph?????????,???Stop 3)??IMediaSeekingSetPosit
ion???(1)?????????????? 4)??IMediaSeekingSetRate
???????? 5)????Filter Graph?????????,???????
??IMediaSeeking???GetCurrentPosition?SetPosition
????????????
50????
DirectShow?????,????????Filter Graph
Manager???????????????????(Event
Notification),??Filter??????????????????????,?????
??????,?Filter Graph Manager???????????,??????????
,??????????????? ??????IMediaEventGetEven
t?????????????????????????????????????????????????
????,???????????????,?????????????????,????????,??
?????GetEvent??,???????,?????????
51?????
DirectShow????????Filter
Graph???????????,???????Render Filter???Sample????
?Video Render?Audio Render??Sample???????????????
??,?????Sample????????Sample???????,???????Sample?
???Sample,??????????Sample?????Sample???????,?Ren
der Filter??,??Sample?????????????,?????????Sample
????
52include ltdshow.hgt include ltstreams.hgt pragma
comment(lib, "strmbasd.lib") //
????????? ......... IGraphBuilder pGraph
NULL IMediaControl pControl NULL IMediaEvent
pEvent NULL // ??????? HRESULT hr
CoInitialize(NULL) // ???COM? .......... hr
CoCreateInstance(CLSID_FilterGraph, NULL,
CLSCTX_INPROC_SERVER, IID_IGraphBuilder,
(void)pGraph) // ??Filter Graph
Manage?? ......... hr pGraph-gtQueryInterface(IID
_IMediaControl, (void)pControl) hr
pGraph-gtQueryInterface(IID_IMediaEvent,
(void)pEvent) hr pGraph-gtRenderFile(Lxxxxxx
xx.avi", NULL) // ??Filter Graph ........... hr
pControl-gtRun() // ?????? ........... long
evCode pEvent-gtWaitForCompletion(INFINITE,
evCode) // ?????? pControl-gtRelease() pEvent-gt
Release() pControl-gtRelease() CoUninitialize()
// ?????????COM?
53- DirectShow????????????????????,??????????,??Direc
tShow?VFW ????????,???????????,???????????????????
?
54THANKS