Re: [問題] 用QTKit從iSight上面擷取每一張畫面

看板MacDev作者 (mactaris)時間14年前 (2010/10/03 16:57), 編輯推噓2(209)
留言11則, 2人參與, 最新討論串4/5 (看更多)
※ 引述《ryanliang (暑假閒閒的大學生~~)》之銘言: : ※ 引述《zonble (zonble)》之銘言: : : QTMovie 有兩個 method : : - (NSImage *)frameImageAtTime:(QTTime)time : : - (void *)frameImageAtTime:(QTTime)time withAttributes:(NSDictionary *)attributes error:(NSError **)errorPtr : : 這兩個 method 可以讓你在取得了一段 QuickTime movie 後 : : 根據時間把 NSImage 或其他的 Image 物件抽出來,不知道 : : 這是不是你想要的? : Z大的意思是, : 我先錄影片,錄完後在用QTMovie中的方法, : 擷取某特定時間點的Frame, : 是這意思嗎? : 跟我原本的流程好像有點不大相同, : 我是想在我按下錄影鍵後的每一張圖(Frame)都存在一個地方, : 也就是說我不打算輸出成影片檔, : 我要的是圖檔, : 不過如果Z大說的方法如果可以找得出"每一張"圖(Frame)的話, : 那倒也不是不可行, : 感謝Z大!! QTCaptureVideoPreviewOutput 有一個 delegate method - (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection 可以擷取 frame QTCaptureDecompressedVideoOutput 也有一個 delegate method - (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection 可以擷取 frame 應該就是你要找的功能了吧 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.111.97

10/03 19:32, , 1F
感謝m大!! 這個方法我都有找到 但是不知怎麼去使用它
10/03 19:32, 1F

10/03 19:33, , 2F
能夠更舉體解說看看嗎? 感謝~~
10/03 19:33, 2F

10/04 04:44, , 3F
你應該看過 StillMotion 這個官方的範例了吧?
10/04 04:44, 3F

10/04 04:45, , 4F
問題在於你要每個 frame 都存起來
10/04 04:45, 4F

10/04 04:47, , 5F
這兩個 delegate method 會把每一個 frame 都 pass 給你
10/04 04:47, 5F

10/04 04:49, , 6F
所以得確定下一個frame進來之前來得及把這個frame存檔
10/04 04:49, 6F

10/04 04:51, , 7F
或者把frame丟給別人(thread?)去存檔...
10/04 04:51, 7F

10/04 12:05, , 8F
沒錯!!會來不及存檔 而且程式會當掉 thread我沒有寫過
10/04 12:05, 8F

10/04 12:07, , 9F
我不知道該怎麼將它分開 我是想按addFrame時可以將Frame
10/04 12:07, 9F

10/04 12:08, , 10F
存起來 現在看來用迴圈寫會當掉 thread我沒研究過 M大有
10/04 12:08, 10F

10/04 12:08, , 11F
甚麼好建議嗎?
10/04 12:08, 11F
文章代碼(AID): #1Cg4LycL (MacDev)
文章代碼(AID): #1Cg4LycL (MacDev)