OpenCV Adventure
Monday, October 14, 2019
Friday, November 16, 2012
Install Target on OpenCV WS2010
Explicitly Select and Build the 'INSTALL' project under OpenCV Solution would install the built binaries, libraries, headers to the directory configured by CMake. This makes building applications against it much easier.
Tuesday, June 19, 2012
Build OpenCV 2.4.1 HTML Doc on Win7-x64
From CMake-GUI 2.8:
- Check BUILD > BUILD_DOCS option
- Download and install MikTex Portable Package
- Use MikTeX Package Manager to install 'latex2html'.
- Specify Ungrouped Entries > MIKTEX_BINARY_PATH "C:\ProgramData\MikTex2.9 Portable\miktex\bin\"
- The rest of that associated binaries (like BIBTEX_COMPILER) will be found in that directory.
- Math expressions will not appear correctly without latex2html; It still works even without specifying the LATEX2HTML_CONVERTER field in CMake.
- Download and install Python and Sphinx EGG module.
- Specify Ungrouped Entries > SPHINX_BUILD "C:\Python26\Scripts\sphinx-build.exe"
- Download and install Ghostscript package
- Specify GHOSTSCRIPT_BINARY_PATH and GHOSTSCRIPT_LIBRARY_PATH to where Ghostcript package is installed locally.
- 'Configure'
- Verify that the binaries supplied by MikTex package is picked up by CMake (such as BIBTEX_COMPILER).
- Check that the 'Build Documentation' is YES at CMake console.
- Check that the PdfLateX.
- 'Generate'
- Select html_docs project from Solution Explorer and 'Build'.
Tuesday, April 3, 2012
Adding Ogg Video to VideoWriter
Did the following such that OpenCV could write Theora encoded Ogg Video (.ogv) in Win32 environment. Useful as it is a way to embed HTML5 video
Details of FFMPEG build and OpenCV integration is the same as previous post. Not repeating here.
Details of FFMPEG build and OpenCV integration is the same as previous post. Not repeating here.
- Setup MinGW-32 environment.
- Download Ogg, Vorbis and Theora from Xiph.org.
- Configure and Build Ogg, Vorbis and Theora from source - in this order.
- Configure and Build FFMPEG-0.8.2 with --enable-libvorbis and --enable-libtheora enabled.
- Copy the ogg, vorbis and theora archive (.a) to OpenCV, in addition to the updated ffmpeg core libraries. Rebuild opencv_ffmpeg with the new OpenCV library.
- Specify codec with fourcc ('t', 'h', 'e', 'o') and output file extension .ogv in call to VideoWriter::open().
Troubleshooting
- Fourcc for theora used in OpenCV 2.3 is 'theo' not 'ther'
- If theora build ended with error in compiling examples, re-configure with --disable-examples flag. This avoids the error and allows the 'make install' to complete without error, thus copying pkg-config files.
- Use --extra-cflags and --extra-ldflags to specify compile options necessary for ffmpeg to build against the vorbis and theora libraries. The flags could be looked up with pkg-config. (Use PKG_CONFIG_PATH if installed in /usr/local or other non-standard locations).
- FFMPEG 0.8.2 build failed with error in ffplay if --disable-avfilter is specified. Patched with '0001-fix-compilation-error-when-disable-avfilters.patch' (see References)
- The order of ogg, vorbis and theora library specified in opencv_ffmpeg build is important. Will failed with missing symbol link-time error if the common libraries are not specified last (like ogg). It is static build. This is what I used: "-lvorbisenc -lvorbisfile -ltheoraenc -ltheoradec -ltheora -lvorbis -logg"
- Encountered ffmpeg error "Application provided invalid, non monotonically increasing dts to muxer in stream 0". This only happen when I set the output frame rate to certain values such as 5-fps, 15-fps. (Other values might fail, but didn't check). Cross-check with the ffmpeg executable built from the same source. There is no error and the following transcoding succeeded.
$ ./ffmpeg.exe -i-an -vcodec libtheora -f ogg -b 500k -r 15 15fps.ogv
Work-around: Noticed that there is a condition check on AVCodecContext->coded_frame->pts before calling av_rescale_q(). (ffmpeg.c line 1312.) Put the same condition to cap_ffmpeg_impl.h. Problem goes away.
Embed HTML Video
- Apache Configuration: 'AddType' directive to make sure the .ogv is sent to the browser with the intended mime-type.
- Uses <video> tag on HTML to embed inline video.
References
- http://www.html5rocks.com/en/tutorials/video/basics/
- http://diveintohtml5.info/video.html
- Patch for ffmpeg 0.8.2: http://ffmpeg.org/trac/ffmpeg/ticket/400
Saturday, January 7, 2012
Build FFMPEG for OpenCV2.3-Win32
Replacing FFMPEG (32-bit) for OpenCV 2.3 and above:
FFMPEG Build
Replace opencv_ffmpeg.dll
- Install MinGW/MSys (32-bit) with the installer. Note: there is a separate open-source project that's called mingw-w64.
- Install extra packages with mingw-get. Browse through the MinGW sourceforge site for suitable ones.
- Download ffmpeg source release from http://ffmpeg.org
- Download and install pr.exe from MinGW snapshots.
http://creekcodes.blogspot.com/2011/02/msys-pr-not-found.html - Download pkg-config release binaries and depending libraries
http://www.rioki.org/2011/02/16/pkg-config-minimal-fuss.html - Run ffmpeg 'configure' with minimal options: --enable-gpl --enable-version3 --arch=x86 --enable-runtime-cpudetect --enable-w32threads --enable-memalign-hack --disable-avfilter --disable-postproc
- Enable console messages by removing all references to -mwindows in config.mak, that is created by configure script.
http://web.archiveorange.com/archive/v/4q4BhzhM6T9fRaCQN2qg - Run make and make install
Replace opencv_ffmpeg.dll
- Follow instructions at opencv/3rdparty/ffmpeg/readme.txt
- uses 'strip -g' (important to strip only debug symbols) to reduce size of ffmpeg core libraries
- copy the difference in header file also, if any.
Tuesday, December 6, 2011
Building OpenCV 2.2 SDK Package
I built a OpenCV 2.2 package on 64-bit Windows 7 and installed to 32-bit Windows XP. The package is an executable. It includes source(optional), built binaries, docs, samples. It requires NSIS to create the package.
CMake Configuration
CMake Configuration
- Enable BUILD_PACKAGE
- Supply Path to MSVC Runtime Redistributable DLLs
- Disable BUILD_TESTS
- Disable Python support
- Build OpenCV Solution in Debug Configuration
- Build OpenCV Solution in Release Configuration
- Copy opencv.ico to where it is specified in Package.cmake.in
- Copy the opencv.pdf to where it is specified in Package.cmake.in
- Build PACKAGE project in OpenCV Solution
Tuesday, November 22, 2011
Show Running Video Frame Number
Spent some time figuring out which existing (free of charge) media player could display current frame-number or resolutions up to milliseconds. I focused my search on Windows platform.
- VLC:
Unable to find a way to step frame-by-frame - VirtualDub: Yes - it is on by default. Noticed the limited types of media container support. It works with AVI, mpg, but not mp4.
- Media Player Classic: Yes - but I am only able to show it as OSD, not the status / information area.
- Open the video file
- Configure the OSD option to display 'frame number' from Media Player Classic menu: Play -> Filters -> ffdshow Video Decoder -> Properties
- Turn on OSD option from ffdshow (available from windows taskbar)
Subscribe to:
Posts (Atom)