使用opencv分析视频,虽然是要做研究单还要保证程序的工程性(不是只读一下特定AVI式就完了)于是乎选择了支持ffmpeg的opencv2.3 一开始没有问题,程序写的很爽,但是当我想回放一下视频片段的时候,问题一下就出来了:无法使用VideoCapture来准确的定位到视
使用opencv分析视频,虽然是要做研究单还要保证程序的工程性(不是只读一下特定AVI格式就完了)于是乎选择了支持ffmpeg的opencv2.3
一开始没有问题,程序写的很爽,但是当我想回放一下视频片段的时候,问题一下就出来了:无法使用VideoCapture来准确的定位到视频中的某一特定时间
要解决问题:
opencv无法正常回放视频(原因是VideoCapture::set 函数里只有一种关键帧模式,详情参见《OpenCV 2.3.1 中关于cvCaptureProperty()定位不准的问题》)
解决方案:
上面给出的链接文章已经给出了这一问题的解决方案,但是过于笼统(我怀疑他们应该是使用的linux系统),在windows下这一编译过程可以用坑爹来形容。好吧,让我们来回顾一下这一坑爹之旅。
1 要修改的代码部分请参见OpenCV 2.3.1 中关于cvCaptureProperty()定位不准的问题 这里不再重复
2 关键的问题来了:我在windows下使用cmake安装opencv的时候,根本就没有WITH_FFMPEG这个选项,而在网上查到的解决方案都是通过修改cmake而直接搞定的,简直可谓是轻松愉快加嗨皮 ,下面给出windows下需要修改的一些内容。
2.1 先说ffmpeg的下载安装。由于一开始不是很清楚,就去ffmpeg的网站上下了最新版本编译好的程序,结果死活有函数找不到。后来google后发现,原来是因为opencv使用的是0.7x版本的ffmpeg,下载的时候大家注意一下。http://ffmpeg.zeranoe.com/builds/在这里下载,我是懒人,我下的编译完的版本。下载完,你怎么配置环境变量我就不管了,反正最后重新编译opencv时你能想起来就行。
2.2 然后我们可以打开opencv文件夹下面 CMakeLists.txt 这个文件发现
[html] view plaincopy
- if(UNIX)
- set(WITH_FFMPEG ON CACHE BOOL "Include FFMPEG support")
- if(NOT APPLE)
- set(WITH_UNICAP OFF CACHE BOOL "Include Unicap support (GPL)")
- set(WITH_GTK ON CACHE BOOL "Include GTK support")
- set(WITH_GSTREAMER ON CACHE BOOL "Include Gstreamer support")
- set(WITH_V4L ON CACHE BOOL "Include Video 4 Linux support")
- set(WITH_XINE OFF CACHE BOOL "Include Xine support (GPL)")
- endif()
- set(WITH_PVAPI ON CACHE BOOL "Include Prosilica GigE support")
- set(WITH_1394 ON CACHE BOOL "Include IEEE1394 support")
- endif()
找到opencv_highgui这个项目,打开cap_ffmpeg.cpp文件,你会发现这么一段预编译代码
[html] view plaincopy
- #ifdef HAVE_FFMPEG
- #include "cap_ffmpeg_impl.hpp"
- #else
- #include "cap_ffmpeg_api.hpp"
- #endif
2.3 下一步是将你的ffmpeg库的include文件夹加到highgui项目中去,不想细说了,还有就是ffmpeg中的静态链接库。这些没有什么难度。然后编译一下,ok,满屏的错误。
转到cap_ffmpeg_impl.hpp文件,大部分的错误是从这里来的
2.3.1 找不到msinttypes.h文件 上这里下载 http://code.google.com/p/msinttypes/ 然后塞进项目去就行了。
2.3.2 INT64_C, UINT64_C 没定义, 自己定义一下就可以了。在文件中加入
[html] view plaincopy
- #define INT64_C
- #define UINT64_C
2.3.4 如果报错 snprintf 这个函数找不到,我不知道这个函数在那个头文件里,我加上了
[html] view plaincopy
- //snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
- sprintf(oc->filename, filename, "%s");
2.3.6 重新编译highgui项目,替换原有的lib,dll文件。
2.3.7 PS, 貌似还需要删除opencv_ffmpeg.dll文件,这样才能调用正确的帧跳转方法,但是删除opencv_ffmpeg后,程序就无法读取非avi类型媒体文件。 目前原因不明,有时间在慢慢鼓捣吧。
OK,整个坑爹之旅到此结束。
http://blog.csdn.net/sxy0082002/article/details/7450623

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

MySQL is not a programming language, but its query language SQL has the characteristics of a programming language: 1. SQL supports conditional judgment, loops and variable operations; 2. Through stored procedures, triggers and functions, users can perform complex logical operations in the database.

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is an open source relational database management system suitable for data storage, management, query and security. 1. It supports a variety of operating systems and is widely used in Web applications and other fields. 2. Through the client-server architecture and different storage engines, MySQL processes data efficiently. 3. Basic usage includes creating databases and tables, inserting, querying and updating data. 4. Advanced usage involves complex queries and stored procedures. 5. Common errors can be debugged through the EXPLAIN statement. 6. Performance optimization includes the rational use of indexes and optimized query statements.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

InnoDB's lock mechanisms include shared locks, exclusive locks, intention locks, record locks, gap locks and next key locks. 1. Shared lock allows transactions to read data without preventing other transactions from reading. 2. Exclusive lock prevents other transactions from reading and modifying data. 3. Intention lock optimizes lock efficiency. 4. Record lock lock index record. 5. Gap lock locks index recording gap. 6. The next key lock is a combination of record lock and gap lock to ensure data consistency.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),