I'm using hardware encoding via FFMPEG and OpenMAX.
If I'm using FFmpeg h264_omx as a backend for VideoWriter than I get image like this. Colors obviously kind of mixed.
Other codecs work fine. If I'll just re-encode via the FFMpeg command line, the output will be okay.
What is the workaround and where should I look?
Machine: Raspberry Pi 4B+
System: Custom Yocto Distribution (master branches)
OpenCV version: 4.1.0
FFMpeg version: 4.2.2 (build with --enable-omx and --enable-omx-rpi)
I have the same issue with encoding h264 through rtmp...
I believe this is a pixel padding/alignment issue, but I do not know where the issue arises.
Related
I am unable to open a camera on the network using Catalina, Python 3.7 and OpenCV 4.1.2.
I am running an IP Webcam app on a phone that exposes an endpoint as: http://192.168.87.26:8080/video. The following command fails:
import cv2
cap = cv2.VideoCapture('http://192.168.87.26:8080/video')
and the error message is:
OpenCV: Couldn't read video stream from file "http://192.168.87.26:8080/video"
At the same time, a video mp4 file works well. I have added permissions in MacOS such that the default webcam also works.
I have tried with both the pip install opencv-python as well as built an opencv from source, but the error for the video stream does not go away.
FFMPEG is installed in the system. FFPLAY on this URL http://192.168.87.26:8080/video works very well.
$ brew info ffmpeg
ffmpeg: stable 4.2.1 (bottled), HEAD
Play, record, convert, and stream audio and video
https://ffmpeg.org/
/usr/local/Cellar/ffmpeg/4.2.1_2 (287 files, 56.6MB) *
What I am missing?
After some more digging around, I was able to make it work. Looks like I had an old version of Intel OpenVINO around from Mojave days that was interfering with any local version of OpenCV that I would install.
During the exercise, I also figured that building OpenCV from scratch is far better than installing it from pip.
I have developed a program in Visual Studio 10 using OpenCV and C++.
It is processing frames in real-time from a camera.
As output, I get processed IplImages which I show on display as video using cvShowImage.
Now I want to stream these frames/video to an IP address so that user can see it using a browser(mjpeg) or in VLC (H.264). I did some research and got to know about GStreamer. But it is not available for VS10 and all the links are dead.
Is there any other way to do it without rebuilding my OpenCV library?
GStreamer is available for Visual Studio 2019, and works for opencv 4.2.
This is easy, but a lot of space for mistakes. The Gstreamer pipe works. The extended description is available here Tutorial.
I used3)
- OpenCV source opencv-4.2.0
- OpenCV source opencv_contrib-4.2.0
- Cmake 3.17 release candidate 3, This is important.
I used development and runtime installer for MSVC GStreamer
Gstreamer 1.16.2 runtime installer
Gstreamer 1.16.2 development installer
The following steps are common for OpenCV to build from source and OpenCV installation. Additionally, these resources needs to be added during cmake configuration.
Now build OpenCV project generated by CMAKE in Visual Studio 2019. The last important thing is to set environmental variables to find GStreamer Runtime. Into system variable path: add
xxx\1.0\x86_64\bin
xxx\1.0\x86_64\lib
xxx\1.0\x86_64\lib\gstreamer-1.0
You need to use VideoWriter with gstreamer Pipeline.
VideoWriter writer( "appsrc ! videoconvert ! videoscale ! video/x-raw,width=320,height=240 ! theoraenc ! oggmux ! tcpserversink host=192.168.0.116 port=8080 recover-policy=keyframe sync-method=latest-keyframe unit-format=buffers units-max=1 buffers-max=0 sync=true ",
0,
5,
Size(320, 240),
true);
Having Gstreamer 1.22 successfully installed I'm not able to configure the project to build OpenCV. CMake isn't able to find GStreamer on my machine. Any ideas how two address this issue?
Just found the solution:
Cmake is using FindGstreamerWindows.cmake to find GStreamer on Windows, which is using internal an environment variable called "GSTREAMER_DIR" pointing to ..\gstreamer\1.0\x86_64.
Please make sure GSTREAMER_DIR exists on your machine.
I recently compile Opencv 4.2 with GStreamer on Windows. I use settings for GStreamer as on the following pictures. Make sure you point to correct .lib and include directories. all_Library is gstapp-1.0.lib etc, when configuraing CMAKE to compile OpenCV.
I use Opencv 4.2, CMake 3.17.0 release candidate and Gstreamer 1.16.2 MSVC 64-bit (VS 2019) developer and runtime installer. The whole process is described here install OpenCV on windows GStreamer tutorial
The important part is to set up environmental variables to find Gstreamer Runtime. Into system variable path: add
xxx\1.0\x86_64\bin
xxx\1.0\x86_64\lib
xxx\1.0\x86_64\lib\gstreamer-1.0
Gstreamer pipe from c++ opencv program to the web.
I am trying to install the Projector-Camera Calibration software available on: http://mesh.brown.edu/calibration/ . The software demands having installed Qt 4.8.4 and OpenCV 2.4.3 on my computer. It cannot work (as far as i know according to my research and INSTALL.txt file in the installation package) with any other versions of Qt and OpenCV. My problem is that OpenCV 2.4.3 version is no longer available anywhere on the Internet to download. It is not even available on the official OpenCV website: http://opencv.org/releases.html . I've tried downloading other versions of OpenCV, but none of them seems to work with this calibration software. More specifically, when I try to execute nmake release command in my Developer Command Prompt for VS 2017, the
LINK : fatal error LNK1181: cannot open input file
'opencv_core243.lib'
message is displayed which is expected because other versions of OpenCV do not have opencv_core243.lib file. I've done everything demanded in INSTALL.txt file, the PATH variable is set properly and everything else.
Can anybody help me with this problem or send me a link for downloading the OpenCV 2.4.3 if it is available somewhere on the Internet?
I don't see why the library should be dependent on that version of OpenCV. From my experience, the camera calibration functions are very stable through different versions.
You should be able to build the library with other versions of OpenCV by editing the file projector-calib.pro from:
# Windows 7
win32:OPENCV_DIR = "C:/opencv/opencv-2.4.3/opencv/build"
win32:OPENCV_LIB_DIR = $$OPENCV_DIR/x86/vc10/lib
win32:CV_VER = 243
to:
# Windows 7
win32:OPENCV_DIR = "C:/{YOUR_PATH}/opencv/build"
win32:OPENCV_LIB_DIR = $$OPENCV_DIR/{x64/x86}/vc12/lib
win32:CV_VER = {VERSION}
and substituting {YOUR_PATH}, {X64/X86} and {VERSION} properly. For OpenCV 2.4.13, for example, {VERSION} is 2413.
I have a problem trying to get a webcam in OpenCV 2.3 to work with Cygwin. I have a Windows 7 64-bit system and I use Notepad++ and cygwin compilers to do my C++ programming. I have seen other posts with similar problems:
Getting Webcam to work in OpenCV
Can't access webcam with OpenCV
I first tried installing OpenCV via the Cygwin Ports. This is rather easy to install, but alas I run into the webcam problem (always returns false when trying to find a device). I have also attempted to build OpenCV and install manually using the command line flavor of CMake. I tried adding the HAVE_VIDEOINPUT and HAVE_DSHOW flags, but no dice. All my programs compile nicely and I have all the functionality of OpenCV aside for this webcam thing.
Has anyone successfully built OpenCV 2.3 on Cygwin with webcam working?
It is unlikely that cygwin build of OpenCV will be able to access a webcam. At least it is not possible without hacking OpenCV cmake scripts. Under cygwin OpenCV build always follows the UNIX branch and videoinput/directshow is excluded from build.