2014-03-05 24 views
0

任務:組織佳能500D相機的liveview流式傳輸...只是流式傳輸而不錄製。當從佳能500D凸輪獲得實時視圖時,爲什麼我的FPS較低?

環境:Windows 7,佳能500D通過USB2.0

一切正常,但我有可怕的低的FPS畫面閃爍。

我有一個計時器。我結合的OnTimer下一個函數:

function TCanonCamera.CMD_StartLiveView: EdsError; 
var 
    prop: EdsUInt32; 
    err : EdsError; 
begin 
    prop := 1; 
    err := SetProperty(kEdsPropID_Evf_Mode, prop); 
    prop := EdsUInt32(kEdsEvfOutputDevice_PC); 
    err := SetProperty(kEdsPropID_Evf_OutputDevice, prop); 
    Result := err; 
end; 

然後我從照相機下載圖像到流負載JPG:TJPEGImage從流:

function TCanonCamera.DownloadLiveViewData: EdsError; 
var 
    err : EdsError; 
    stream : EdsStreamRef; 
    EvfImageRef: EdsEvfImageRef; 
    prop: EdsUInt32; 
    ImageData : Pointer; 
    ImageSize : EdsUInt32; 
    ImageStream: TmemoryStream; 
    jpg: TJPEGImage; 
begin 
    err := EDS_ERR_OK; 

    err := EdsCreateMemoryStream(0, stream); 

    if err = EDS_ERR_OK then 
    err := EdsCreateEvfImageRef(stream, EvfImageRef); 

    if err = EDS_ERR_OK then 
    err := EdsDownloadEvfImage(FCameraRef, EvfImageRef); 

    if err = EDS_ERR_OK then 
    begin 
    EdsGetPointer(Stream, ImageData); 
    EdsGetLength(Stream, ImageSize); 

    ImageStream := TMemoryStream.Create; 
    ImageStream.WriteBuffer(ImageData^, ImageSize); 

    ImageStream.Position := 0; 

    if Assigned(FEvfImageUpdatedEvent) then 
    begin 
     jpg := TJPEGImage.Create; 
     jpg.LoadFromStream(ImageStream); 
     FEvfImageUpdatedEvent(jpg); 
    end; 
    ImageStream.Free; 
    end; 

    EdsRelease(EvfImageRef); 
    EdsRelease(stream); 

    Result := err; 
end; 

然後我渲染JPG到的TImage:

procedure TfrmMain.OnLiveViewImageUpdate(jpg: TJPEGImage); 
begin 
    imLiveview.Picture.Assign(jpg); 
    jpg.Free; 
end; 

因此,我在TImage上得到了閃爍的圖像。 我嘗試設置任何值到計時器的時間間隔,但沒有顯着成功。

我應該怎麼做才能加速流式傳輸?

謝謝。

更新:我懷疑主要觀點是我在單線程應用程序中執行所有步驟...您怎麼看待它?我應該執行分離的線程以獲取來自相機的實時圖像嗎?

+0

您可以刪除'err:= EDS_ERR_OK;'。好的,這對fps沒有幫助.. –

+0

是的。您必須啓用警告,然後聽取警告。這是良性的,因爲它發生。但是,真的,爲什麼你會寫:'x:= 1; x:= f(y);'?如果你啓用了警告,編譯器會告訴你這是徒勞的。 –

+1

你也可以嘗試['更快的JPEG解碼器](http://blog.synopse.info/post/2010/03/24/Fast-JPEG-decoder-using-SSE/SSE2-version-1.2)。 – TLama

回答

2

關閉關於它的未來問題。 解決方案是由@TLama和一些簡單的額外步驟提示快速JPEG解碼:

procedure TfrmMain.OnLiveViewImageUpdate(bmp: TBitmap); 
begin 
    bmp.IgnorePalette := true; 
    imLiveview.Canvas.Draw(0,0,bmp); 
    Application.ProcessMessages; 
    bmp.Free; 
end; 
像真正的視頻中實時查看數據流後

感謝您的幫助。

相關問題