使用OpenCV玩家营造出一个视频控制(没有声音)
? ? ? ? ? 說明:OpenCV計算機視覺庫,所以使用的圖像或視頻處理,因此,沒有任何聲音在播放視頻的臨時
? ? ? ? ? ? 軟件:使用OpenCV制播放器(無聲音)
? ? ? ? ? ? 功能說明:新建播放窗體。加入進度條能夠拖動視頻播放。
? ? ? ? ? ? 流程圖:
? ? ? ? ? ? ??
? ? ? ? ? ? 功能說明:
? ? ? ? ? ? ? 1. 新建進度條 cvCreatTrackbar("","",&,frames,callback)
? ? ? ? ? ? ? 2、獲取總幀數 cvGetCaptureProperty(&,id)?
? ? ? ? ? ? ? ? ??double cvGetCaptureProperty( CvCapture* capture, int property_id );capture 視頻獲取結構。property_id 屬性標識。能夠是以下之中的一個:CV_CAP_PROP_FRAME_COUNT - 視頻文件里幀的總數
? ? ? ? ? ? ? ?3.回調函數 cvSet(&。id, pos)
? ? ? ? ? ? ? ?int cvSetCaptureProperty( CvCapture* capture, int property_id, double value )property_id 屬性標識符。能夠是以下之中的一個:CV_CAP_PROP_POS_FRAMES - 單位為幀數的位置(僅僅對視頻文件有效)
? ? ? ? ?
? ? ? ? ?源碼:
? ?
#include”cv.h” #include”highgui.h”int g_slider_position=0; CvCapture* g_capture =NULL;void CvTrackcalllback(int pos) {cvSetCaptureProperty( g_capture, CV_CAP_PROP_POS_FRAMES, pos );}int main(int argc, char** argv) {cvNamedWindow("Example3",CV_WINDOW_AUTOSIZE);g_capture = cvCreateFileCapture("視頻路徑");int frames = (int)cvGetCaptureProperty(g_capture,CV_CAP_PROP_FRAME_COUNT);if(frames!=0) {cvCreateTrackbar("Test","Example3",&g_slider_position,frames,CvTrackcalllback);}IplImage* frame; while(1) {frame = cvQueryFrame(g_capture)cvShowImage("Example3",frame); cvWaitKey(0); } return 0; }? ? ? ? ? ? ?? ? ? ? ? ? 執行結構截圖例如以下:
? ? ? ? ??
? ? ? ? ? ? 有問題,愿意與大家交流!
版權聲明:本文博客原創文章,博客,未經同意,不得轉載。
轉載于:https://www.cnblogs.com/mengfanrong/p/4711924.html
總結
以上是生活随笔為你收集整理的使用OpenCV玩家营造出一个视频控制(没有声音)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (连通图 模板题 无向图求桥)Criti
- 下一篇: Zepto 与 jQuery 的区别 小