想請問大大~我想一次擷取三個螢幕影像該怎麼做呢? |
尚未結案
|
ZZAAQQ
一般會員 發表:1 回覆:0 積分:0 註冊:2009-12-30 發送簡訊給我 |
//---------------------------------------------------------------------------
#include #include #pragma hdrstop #include "MultiCams_.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma link "VidGrab" #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::SetupVideoCaptureDevice (TVideoGrabber *VideoGrabber, int VideoDeviceIndex) { VideoGrabber->VideoDevice = VideoDeviceIndex; VideoGrabber->AutoFilePrefix = "cam" IntToStr (VideoDeviceIndex 1) "_"; VideoGrabber->DVReduceFrameRate = True; VideoGrabber->FrameRate = 15; VideoGrabber->ReducePreviewCPULoad = true; VideoGrabber->UseNearestVideoSize (320, 240, true); } //--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender) { SetupVideoCaptureDevice (VideoGrabber1, 0); SetupVideoCaptureDevice (VideoGrabber2, 1); SetupVideoCaptureDevice (VideoGrabber3, 2); Edit3->Text = VideoGrabber1->StoragePath; // we use a common storage path in this project } //--------------------------------------------------------------------------- void __fastcall TForm1::ProcessFrameCapture (TVideoGrabber *VideoGrabber) { switch (RadioGroup1->ItemIndex) { case 0: VideoGrabber->CaptureFrameTo (fc_TBitmap ); break; case 1: VideoGrabber->CaptureFrameTo (fc_JpegFile); break; case 2: VideoGrabber->CaptureFrameTo (fc_BmpFile ); break; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { CheckBox1->Checked = false; ProcessFrameCapture (VideoGrabber1); ProcessFrameCapture (VideoGrabber2); ProcessFrameCapture (VideoGrabber3); } //--------------------------------------------------------------------------- void __fastcall TForm1::ProcessAutomaticCapture (TVideoGrabber *VideoGrabber) { if (CheckBox1->Checked) { switch (RadioGroup1->ItemIndex) { case 0: VideoGrabber->BurstType = fc_TBitmap ; break; case 1: VideoGrabber->BurstType = fc_JpegFile; break; case 2: VideoGrabber->BurstType = fc_BmpFile ; break; } VideoGrabber->BurstCount = 0; VideoGrabber->BurstMode = true; VideoGrabber->BurstInterval = StrToIntDef (Edit2->Text, 0); else { VideoGrabber->BurstMode = false; } } //--------------------------------------------------------------------------- void __fastcall TForm1::CheckBox1Click(TObject *Sender) { ProcessAutomaticCapture (VideoGrabber1); ProcessAutomaticCapture (VideoGrabber2); ProcessAutomaticCapture (VideoGrabber3); } //--------------------------------------------------------------------------- void __fastcall TForm1::VideoGrabber1FrameCaptureCompleted(TObject *Sender, const TFrameData &FrameData, TFrameCaptureDest DestType, AnsiString FileName, bool Success) { Image1->Picture->Bitmap->Assign (FrameData.Bitmap); if (DestType != fc_TBitmap) { Memo2->Lines->Add (FileName); Memo2->Lines->Add (""); } } //--------------------------------------------------------------------------- void __fastcall TForm1::VideoGrabber2FrameCaptureCompleted(TObject *Sender, const TFrameData &FrameData, TFrameCaptureDest DestType, AnsiString FileName, bool Success) { Image2->Picture->Bitmap->Assign (FrameData.Bitmap); if (DestType != fc_TBitmap) { Memo2->Lines->Add (FileName); Memo2->Lines->Add (""); } } //--------------------------------------------------------------------------- void __fastcall TForm1::VideoGrabber3FrameCaptureCompleted(TObject *Sender, const TFrameData &FrameData, TFrameCaptureDest DestType, AnsiString FileName, bool Success) { Image3->Picture->Bitmap->Assign (FrameData.Bitmap); if (DestType != fc_TBitmap) { Memo2->Lines->Add (FileName); Memo2->Lines->Add (""); } } //--------------------------------------------------------------------------- void __fastcall TForm1::VideoGrabber4FrameCaptureCompleted(TObject *Sender, const TFrameData &FrameData, TFrameCaptureDest DestType, AnsiString FileName, bool Success) { if (DestType != fc_TBitmap) { Memo2->Lines->Add (FileName); Memo2->Lines->Add (""); } } //--------------------------------------------------------------------------- void __fastcall TForm1::RadioGroup1Click(TObject *Sender) { CheckBox1Click (CheckBox1); } //--------------------------------------------------------------------------- void __fastcall TForm1::SpeedButton7Click(TObject *Sender) { AnsiString Dir = VideoGrabber1->StoragePath; if (SelectDirectory (Dir, TSelectDirOpts() << sdAllowCreate << sdPerformCreate << sdPrompt, 0)) { Edit3->Text = Dir; VideoGrabber1->StoragePath = Dir; VideoGrabber2->StoragePath = Dir; VideoGrabber3->StoragePath = Dir; } } //--------------------------------------------------------------------------- 這是顯示視訊的程式,我想把之前版面大大的錄影程式插入的話,我該怎麼改呢? 這是前面文章裡找到的程式,我要如何修改呢?(因為有興趣想知道怎麼做~可以教教我嗎?)此段引用MilesWamg 的程式 void __fastcall TForm1::FormCreate(TObject *Sender) { //建立使用物件 Rec = new TRec(this->Handle); //啟動錄影畫面 Rec->ShowLive(0); Capflag=false; Pic = new Graphics::TBitmap(); Pic->Height=240; Pic->Width=320; Pic->PixelFormat=pf24bit; Pic2 = new Graphics::TBitmap(); Pic2->Height=240; Pic2->Width=320; Pic2->PixelFormat=pf24bit; Pic->Canvas->Font->Color =clBlue; Pic->Canvas->Brush->Style = bsDiagCross; avi = CreateAvi("Test.avi",50,NULL); OPflag=true; AVI_Frame_Count=0; } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { if(Capflag==false) { Capflag=true; Button2->Caption="關閉"; Timer1->Enabled=true; Rec->Record(); //等待觸發錄影 Rec->Overlay(true); } else { Capflag=false; Button2->Caption="啟動"; Timer1->Enabled=false; Rec->Stop(); if(OPflag==true) { CloseAvi(avi); OPflag=false; } } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender) { Form1->Close(); } |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |