Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux builds failing. Both 2.5.1 and latest git revision #30

Closed
CursedSilicon opened this issue Sep 24, 2022 · 6 comments
Closed

Linux builds failing. Both 2.5.1 and latest git revision #30

CursedSilicon opened this issue Sep 24, 2022 · 6 comments

Comments

@CursedSilicon
Copy link

Hi team,

I've been trying to build this program to use my E1S for retro machine capture under Linux (using Windows for the capture machine is unfortunately not possible)

When attempting to compile it I experience the following errors

/usr/include/opencv2 does not actually exist. On my machine the files vcs is searching for exist under /usr/include/opencv4/opencv2 however symlinking the directory to /usr/include/opencv2 allows the build to continue

During the make operation it quickly fails with the following error

src/filter/filters/delta_histogram/filter_delta_histogram.cpp:67:96: error: ‘CV_AA’ was not declared in this scope

Adding #define CV_AA cv::LINE_AA to the histogram.cpp file allows the build to continue for some time, eventually erroring out at the following however

generated_files -Igenerated_files -I../../../lib64/qt5/mkspecs/linux-g++ -o generated_files/scaler.o src/scaler/scaler.cpp
src/scaler/scaler.cpp: In function ‘void s_convert_frame_to_bgra(const captured_frame_s&)’:
src/scaler/scaler.cpp:490:30: error: ‘CV_BGR5652BGRA’ was not declared in this scope
  490 |             conversionType = CV_BGR5652BGRA;
      |                              ^~~~~~~~~~~~~~
src/scaler/scaler.cpp:494:30: error: ‘CV_BGR5552BGRA’ was not declared in this scope
  494 |             conversionType = CV_BGR5552BGRA;
      |                              ^~~~~~~~~~~~~~
src/scaler/scaler.cpp:503:34: error: ‘CV_RGBA2BGRA’ was not declared in this scope
  503 |                 conversionType = CV_RGBA2BGRA;
      |                                  ^~~~~~~~~~~~
src/scaler/scaler.cpp:507:34: error: ‘CV_BGR2BGRA’ was not declared in this scope
  507 |                 conversionType = CV_BGR2BGRA;
      |                                  ^~~~~~~~~~~
src/scaler/scaler.cpp:511:34: error: ‘CV_BGR5652BGRA’ was not declared in this scope
  511 |                 conversionType = CV_BGR5652BGRA;
      |                                  ^~~~~~~~~~~~~~
make: *** [Makefile:7075: generated_files/scaler.o] Error 1

Unfortunately I'm not a C++ programmer so this error is beyond my ability to correct.

Is there something I'm missing from the build on my machine? I am using the latest opencv-v4.6.0 which I am not sure if may be contributing to the issue.

I have seen @AkBKukU using this same card on their streams, albeit using a Ubuntu LTS which I assume includes a much older version of opencv?

@Archaemic
Copy link

I helped @CursedSilicon get it to build by adding a few includes:

diff --git a/src/capture/vision_v4l/input_channel_v4l.cpp b/src/capture/vision_v4l/input_channel_v4l.cpp
index 46dd627..80970a6 100644
--- a/src/capture/vision_v4l/input_channel_v4l.cpp
+++ b/src/capture/vision_v4l/input_channel_v4l.cpp
@@ -13,6 +13,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <cstring>
+#include <thread>
 #include <linux/videodev2.h>
 #include "capture/vision_v4l/input_channel_v4l.h"
 #include "capture/vision_v4l/ic_v4l_video_parameters.h"
diff --git a/src/filter/filters/delta_histogram/filter_delta_histogram.cpp b/src/filter/filters/delta_histogram/filter_delta_histogram.cpp
index 6a99a8f..8dc8f63 100644
--- a/src/filter/filters/delta_histogram/filter_delta_histogram.cpp
+++ b/src/filter/filters/delta_histogram/filter_delta_histogram.cpp
@@ -9,6 +9,7 @@
 
 #ifdef USE_OPENCV
     #include <opencv2/imgproc/imgproc.hpp>
+    #include <opencv2/imgproc/imgproc_c.h>
     #include <opencv2/photo/photo.hpp>
     #include <opencv2/core/core.hpp>
 #endif
diff --git a/src/record/record.cpp b/src/record/record.cpp
index f644448..a67ac0b 100644
--- a/src/record/record.cpp
+++ b/src/record/record.cpp
@@ -29,6 +29,7 @@
 #ifdef USE_OPENCV
     #include <opencv2/core/core.hpp>
     #include <opencv2/imgproc/imgproc.hpp>
+    #include <opencv2/imgproc/types_c.h>
     #include <opencv2/videoio/videoio.hpp>
 
     static cv::VideoWriter VIDEO_WRITER;
diff --git a/src/scaler/scaler.cpp b/src/scaler/scaler.cpp
index 78785fb..961d39e 100755
--- a/src/scaler/scaler.cpp
+++ b/src/scaler/scaler.cpp
@@ -23,6 +23,7 @@
 
 #ifdef USE_OPENCV
     #include <opencv2/imgproc/imgproc.hpp>
+    #include <opencv2/imgproc/types_c.h>
     #include <opencv2/core/core.hpp>
 #endif
 

@leikareipa
Copy link
Owner

Yeah, OpenCV has been giving build issues in this project for a while. It's because VCS is still sticking with an old version of it (3.2.0) to support 32-bit Windows XP. Like you noticed, e.g. "CV_AA" is now called "cv::LINE_AA", so you get errors about the old names not being defined when using newer OpenCV.

It should be possible to install OpenCV 3.2.0 on newer Linux (I have it on Ubuntu 20.04), but I can't remember how. You might need to build it from source, so it's a bit of a hassle.

The headers @Archaemic mentions look to be for OpenCV's C API? I guess it might be a deprecated feature if it still provides the old OpenCV names, but if it works with newer OpenCV then it's probably fine for now.

One other way to fix it is to replace the old, erroring OpenCV names in VCS's code with their current versions. You can probably find out what they're called now just by googling for the old name and "error" or something like that. I tried it about a year or so ago and it was possible without too much work at that point.

I've been thinking about dropping XP support in VCS. It's mainly for capturing in virtual machines, where I've seen better performance out of XP than e.g. Windows 7. But I'd need to do some testing first to see if that's changed. In any case, when that dropping happens, the project can upgrade to newer OpenCV.

@CursedSilicon
Copy link
Author

I tried to build it on Gentoo which only ships OpenCV 4. Interestingly (as far as I could tell) OpenCV had versions 3 and 4 in parallel for quite a while(?) Gentoo meanwhile dropped v3 somewhere around 2018-2019 which would've made bringing it back a bit daunting (mis-matched dependencies, much newer compiler etc)

@Archaemic's quick edits made it build and run fine on v4 for me. I've been using it to capture game footage absolutely flawlessly since yesterday now. I'm not sure if they'll break v3 compat or not, but it might be worth adding as a note or something for other users.

Datapath's binary blobs build fine against Kernel 5.10 LTS versions which makes using a newer distro fine as long as you can rebase the kernel against it

@leikareipa
Copy link
Owner

I'll keep this issue open for now for people to stumble onto and get the answer. The problem will probably keep getting more common as older distros go end of life.

Officially I'll still recommend using OpenCV 3.2.0 since that's what the project expects for now, and letting me know if the build instructions for it in the VCS readme don't work on a particular distro or if there's any other problem with the process.

@leikareipa
Copy link
Owner

Since the code works with the C API headers, I wonder to what extent it's not just a case of VCS incorrectly using OpenCV's C API constants like CV_AA rather than the C++ API ones like cv::LINE_AA.

Looking at it now, it seems cv::LINE_AA is already defined in OpenCV 3.2.0, and things like CV_BGR2BGRA look to have equivalents like cv::COLOR_BGR2BGRA in both 3.2.0 and the newest 4.6.x.

Once I have time, I'll replace those C constants with their C++ variants and see whether that alone would be enough to get better cross-version compilation.

@leikareipa
Copy link
Owner

Commit 4f7e0d1 replaces the use of OpenCV C constants with C++ ones.

I tested it briefly in a VM with Ubuntu 22.04 and OpenCV 4.x (whichever version you get with a default install). Looked to compile and run ok after adding OpenCV's header directory to the Linux INCLUDEPATH in vcs.pro.

I haven't tested the change in Windows or in any broad sense otherwise, so maybe it regresses something, but maybe not.

I'll close the issue for now, but let me know if there are problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants