How to build openCV 3.3.0 with GStreamer on Windows - opencv

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.

Related

Stream processed frame from openCV to IP

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);

Why cv_bridge uses OpenCV 3.2 in ROS Melodic?

I have OpenCV 3.4 installed in Ubuntu 18. I also have installed ROS Melodic according to the website instructions. However, I keep on getting an error that libopencv_core.so.3.2 is required.
I already set my CMakeLists files to point to OpenCV 3.4.
However, I found out that in the file:
/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
there is the following line hardcoded in opencv3.2:
set(libraries "cv_bridge;/usr/lib/x86_64-linux-gnu/libopencv_core.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgproc.so.3.2.0;/usr/lib/x86_64-linux-gnu/libopencv_imgcodecs.so.3.2.0").
I tried to change it to 3.4 but I can not rebuild it.
The error I am getting is:
/opt/ros/melodic/lib/image_view/image_view: error while loading shared libraries: libopencv_core.so.3.2: cannot open shared object file: No such file or directory
Why is OpenCV 3.2 hardcoded in cv_bridge and how can I rebuild it with OpenCV 3.4?
Update:
I eventually installed OpenCV 3.2 and it worked properly.
Because opencv development speed is much faster than ROS individual module. And a lot of ROS modules went depreciated after someone left the job.
But that's by no means the end of the day( maybe end of the day for noobs). You can build it directly with any version of opencv core function(besides imshow kind of function) others should perform just fine.
The easiest way is to do is: in the console before executing catkin_make try to execute the following
export CMAKE_PREFIX_PATH=/usr/local:$CMAKE_PREFIX_PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
This should give preference to your custom OpenCV installation when doing the find_package(OpenCV 3.X.0 REQUIRED). Then compile and use the function of that version.
Well if you do have to use 3.4 then I think you have to build ros version of opencv and image transport and cvbridge to the 3.4 if that's what you are targeting.
You can find the link here https://github.com/ros-gbp/opencv3-release The highest they provide seems to be 3.3

OpenCV 2.4.3 release cannot be found to download

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.

Why doesn't CLion link my project with OpenCV for Windows?

I'm attempting to use OpenCV for Windows as supplied by opencv.org in a project I'm building with JetBrains' CLion IDE. I've installed the opencv library and configured CLion (set(OpenCV_DIR) to reference the build directory under it, but CMake issues the warning:
Found OpenCV Windows Pack but it has no binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
I've tried some of the older distributions from opencv.org with the same results. It appears CMake is locating the OpenCV libraries, but doesn't want to use them. Why, and how do I get the OpenCV libraries to work under CLion?
The short answer is, you will probably need to build OpenCV from source in order to use it with CLion. But given the number and range of partially answered and unanswered questions here* and elsewhere on using JetBrains' CLion IDE with the OpenCV library, I think an overview is needed (my notes are from CLion 2016.3 and OpenCV 3.1, YMMV):
Though not produced by JetBrains, CMake is very central to CLion's operation. Understanding CMake therefore helps greatly in diagnosing CLion build problems. In particular CMake maintains a disk "cache" of settings which you may need to clear to incorporate changes to your environment (Tools->CMake->Reset Cache and Reload Project).
To make use of OpenCV in your build you must specify it in your project's CMakeLists.txt file. You request that CMake locate your OpenCV location and link it to your TARGET. An example of a sequence of commands from CMakeLists.txt for an executable named mushroom follows:
add_executable(mushroom ${SOURCE_FILES})
FIND_PACKAGE(OpenCV REQUIRED)
TARGET_LINK_LIBRARIES(mushroom ${OpenCV_LIBS})
(For more on FIND_PACKAGE, see CMake:How To Find Libraries.)
FIND_PACKAGE for package XXX works either by way of FindXXX.cmake files located at CMake's Modules directory, or by consulting environment variable XXXX_DIR. On my system, no FindOpenCV.cmake file was present, so I relied on the OpenCV_DIR environment variable instead. This must be set, not to the root of your OpenCV installation, but to the build folder beneath it. I used an entry in CMakeLists.txt to set this variable, e.g.:
set(OpenCV_DIR C:/Users/myacct/AppData/Local/opencv-3.0.0/build)
To link with OpenCV, CMake uses either FindOpenCV.cmake or OpenCV_DIR (see previous point above) to locate a file named OpenCVConfig.cmake. This file is generated by and ships with a particular build of OpenCV in order to document what components are present and where they are located.
Problems may occur when variable names used by OpenCVConfig.cmake conflict with those CLion has stored in its environment. In particular, if your OpenCV was built by Microsoft Visual C (MSVC), as is the Windows distribution from opencv.org, it won't work with CLion.
Because CLion's build toolchain (ControlAltS-toolchain) uses either MinGW or Cygwin, OpenCVConfig.cmake will search for OpenCV binaries under a subdirectory named mingw or cygwin and will find none because the binaries were built with MSVC (it will look in a directory like vc11 or vc12 instead). This probably means you will need to build OpenCV from source in order to use it with CLion.
Would reconfiguring OpenCVConfig.cmake to point to the MSVC binaries make this work? you may ask. Unfortunately the answer is still no, because libraries built with one compiler typically cannot be linked with another one.
OpenCVConfig.cmake or FindOpenCV.cmake likely contain diagnostic messages, but when CLion executes CMake for you, message(STATUS) calls are not displayed. To make them display, change them to message(WARNING) or message(FATAL_ERROR). But CLion 2016.3 EAP relieves this problem; see https://stackoverflow.com/a/39398373/5025060.
CLion does not indicate which .cmake script issued which diagnostics; don't assume they all come from the same script.
Hopefully this provides some general guidance on resolving CLion / CMake / OpenCV compatibility problems. Note that this does not cover compiler or linker issues; these will not appear until CMake completes its initial makefile build. Compiler or linker issues occur at a later stage and are controlled by include*(), link*() and other commands in CMakeLists.txt.
*Some related SO questions:
OpenCV Windows setup with CLion
OpenCV CLion (Cmake) linking issue - cmake reports a strange error
use OpenCV with Clion IDE on Windows
Compiling OpenCV on Windows with MinGW
Could not find module FindOpenCV.cmake ( Error in configuration process)
CMake: Of what use is find_package() if you need to specify CMAKE_MODULE_PATH anyway?

Getting webcam to work in OpenCV 2.3 with Cygwin

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.

Resources