我最近一直试图找到一种快速有效的方法,使用Python语言在两个数组之间执行互相关检查.经过一番阅读,我发现了以下两个选项:
NumPy.correlate()
方法在大型数组时速度太慢.cv.MatchTemplate()
方法似乎要快得多.出于显而易见的原因,我选择了第二个选项.我试图执行以下代码:
import scipy
import cv
image = cv.fromarray(scipy.float32(scipy.asarray([1,2,2,1])),allowND=True)
template = cv.fromarray(scipy.float32(scipy.asarray([2,2])),allowND=True)
result = cv.fromarray(scipy.float32(scipy.asarray([0,0,0])),allowND=True)
cv.MatchTemplate(image,template,result,cv.CV_TM_CCORR)
Run Code Online (Sandbox Code Playgroud)
即使这段代码非常简单,它也会抛出下一个错误:
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in cvGetMat, file /builddir/build/BUILD/OpenCV-2.1.0/src/cxcore/cxarray.cpp, line 2476
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cv.error: Unrecognized or unsupported array type
Run Code Online (Sandbox Code Playgroud)
经过几个小时的挫败尝试,我仍然被困住了!有人有什么建议吗?
顺便说一句,这是我的Python版本输出:
Python 2.7 (r27:82500, Sep 16 2010, 18:03:06)
[GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
Type "help", "copyright", "credits" …
Run Code Online (Sandbox Code Playgroud) 可能重复:
ffmpeg:转换前后的视频长度不同
最近,我一直试图将FFmpeg用于一个应用程序,当涉及到时间参数(毫秒分辨率)时需要非常精确的操作.不幸的是,我很惊讶地发现FFmpeg的操作功能会返回一些不准确的结果.
这是'ffmpeg'的输出:
ffmpeg version 0.11.1 Copyright (c) 2000-2012 the FFmpeg developers
built on Jul 25 2012 19:55:05 with gcc 4.2.1 (Apple Inc. build 5664)
configuration: --enable-gpl --enable-shared --enable-pthreads --enable-libx264 --enable-libmp3lame
libavutil 51. 54.100 / 51. 54.100
libavcodec 54. 23.100 / 54. 23.100
libavformat 54. 6.100 / 54. 6.100
libavdevice 54. 0.100 / 54. 0.100
libavfilter 2. 77.100 / 2. 77.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100 …
Run Code Online (Sandbox Code Playgroud)