2011-10-05 2 views
6

Emgu를 사용하여 비디오를 재생할 때보다 빨리 재생됩니다. 다음은 관련 코드입니다.Emgu Capture가 비디오를 매우 빠르게 재생합니다.

public Form1() 
{ 
    InitializeComponent(); 

    _capture = new Capture("test.avi"); 
    Application.Idle += RefreshFrames; 
} 

protected void RefreshFrames(object sender, EventArgs e) 
{ 
    imageBox.Image = _capture.QueryFrame(); 
} 

캡쳐 개체에 SetCaptureProperty 메서드를 사용하여 FPS를 설정하려고 시도했지만 여전히 슈퍼 빠른 동작으로 재생됩니다.

답변

11

사용자가 프로그램에서 다른 함수를 호출하지 않고 컴퓨터에 사용 가능한 리소스가 없을 때 Application.Idle 핸들이 호출됩니다. 설정 한 시간에 호출 할 수 있도록 설계되지 않았습니다. 대신 타이머를 설정하고 틱 기능을 사용하여 재생 속도를 설정하십시오.

Timer My_Time = new Timer(); 
int FPS = 30; 

public Form1() 
{ 
    InitializeComponent(); 

    //Frame Rate 
    My_Timer.Interval = 1000/FPS; 
    My_Timer.Tick += new EventHandler(My_Timer_Tick); 
    My_Timer.Start(); 
    _capture = new Capture("test.avi"); 
} 

private void My_Timer_Tick(object sender, EventArgs e) 
{ 
    imageBox.Image = _capture.QueryFrame(); 
} 

위의 코드는 원하는대로 수행해야합니다. 원하는 재생 속도를 얻으려면 FPS를 조정하십시오. 당신은

건배

실시간으로 속도를 재생을 다시 설정하는

크리스

+0

굉장! 감사. 유일하게 누락 된 것 같아요 My_Timer.Start() – a432511

+0

Opps oh yes silly me :) correct Cheers – Chris

+0

@Chris이 타이머는 적절한 해상도를 가지고 있습니까? – gonzobrains

0
public Form1() 
{ 
    InitializeComponent(); 

    _capture = new Capture("test.avi"); 
    Application.Idle += RefreshFrames; 
} 

protected void RefreshFrames(object sender, EventArgs e) 
{ 
    imageBox.Image = _capture.QueryFrame(); 

    Thread.sleep(1000/FrameRate); 
} 

사용 Thread.sleep를 알려 다른 아무것도 필요합니다. 당신은 쉽게 이걸 사용하여 을 얻을 수 있습니다 :)