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

[aravis] add new port (+add to OpenCV 4 as optional feature) #42351

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rursprung
Copy link

@rursprung rursprung commented Nov 25, 2024

please note:

  • i'm not part of the aravis maintainers (i'm just a user)
  • i've tested this under Ubuntu 24.04 in WSL2 using a USB3 VISION camera through OpenCV (with the new aravis feature introduced in this PR) and it worked fine
  • aravis currently builds a couple of binaries (arv-camera-test-0.8, arv-fake-gv-camera-0.8, arv-test-0.8 and arv-tool-0.8) which cannot be disabled at the moment (except with a patch to their build system), i've reported this to upstream: add meson option to build only the library AravisProject/aravis#962. i think they currently don't hurt and it's better if this gets fixed in upstream rather than having a patch here.
  • back in 2019 @cenit already once attempted to package aravis here but that PR was abandoned later: [aravis] new port #8595

resolves #37072
resolves #3411

checklist:

  • Changes comply with the maintainer guide.
  • The name of the port matches an existing name for this component on https://repology.org/ if possible, and/or is strongly associated with that component on search engines.
  • Optional dependencies are resolved in exactly one way. For example, if the component is built with CMake, all find_package calls are REQUIRED, are satisfied by vcpkg.json's declared dependencies, or disabled with CMAKE_DISABLE_FIND_PACKAGE_Xxx.
  • The versioning scheme in vcpkg.json matches what upstream says.
  • The license declaration in vcpkg.json matches what upstream says.
  • The installed as the "copyright" file matches what upstream says.
  • The source code of the component installed comes from an authoritative source.
  • The generated "usage text" is accurate. See adding-usage for context.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Only one version is in the new port's versions file.
  • Only one version is added to each modified port's versions file.

ports/opencv/vcpkg.json Outdated Show resolved Hide resolved
"aravis": {
"description": "aravis",
"dependencies": [
"aravis"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enable opt-out from usb.

Suggested change
"aravis"
{
"name": "aravis",
"default-features": false
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then it might be better to leave usb away as a default feature from aravis? i now went with that option to stay aligned with aravis (though i think they make it dependent on the availability of the library by default since they set it to auto)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vcpkg will install aravis' default feature by default. This change enables the user to explicitly request installation of aravis without default features.

Comment on lines 1 to 5
include(FindPkgConfig)
pkg_search_module(Aravis REQUIRED aravis-0.8)
if (Aravis_FOUND)
set(Aravis_LIBS "aravis-0.8")
endif()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wrapper is pointless and not working correctly.
The code should be added to the consuming projects instead.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this wrapper i can't do find_package(Aravis REQUIRED) - i didn't find any documentation on how to resolve this (even vcpkg-cmake-wrapper.cmake is undocumented beyond the fact that it may exist). how else would you solve this?

Comment on lines 1 to 4
The aravis package provides CMake targets:

find_package(aravis REQUIRED)
target_link_libraries(main PRIVATE ${Aravis_LIBRARIES})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add a usage file here. The tool generates the desired information heristically for pkg-config.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i've removed it.
but then it just says:

aravis provides pkg-config modules:

  # Camera control and image acquisition library
  aravis-0.8

isn't this less helpful than having a clear example on what to do (as is e.g. the case with the usage i had provided)?

ports/aravis/portfile.cmake Outdated Show resolved Hide resolved
ports/aravis/portfile.cmake Outdated Show resolved Hide resolved
ports/aravis/portfile.cmake Outdated Show resolved Hide resolved
@rursprung rursprung force-pushed the add-aravis branch 4 times, most recently from ed919f4 to 16cbe1d Compare November 25, 2024 19:02
@rursprung rursprung changed the title add new port: aravis v0.8 (+add to OpenCV 4 as optional feature) [aravis] add new port (+add to OpenCV 4 as optional feature) Nov 25, 2024
@rursprung rursprung force-pushed the add-aravis branch 2 times, most recently from 51a354c to 69fffe6 Compare November 25, 2024 19:24
@rursprung
Copy link
Author

rursprung commented Nov 25, 2024

@dg0yt: thanks a lot for your super fast review!

i now have one last CI failure in the android CI builds which i don't know how to solve:

../src/0.8.33-e9321ff061.clean/src/arvnetwork.c:352:6: error: call to undeclared function 'getifaddrs'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  352 |         if (getifaddrs (&ifap) <0)
      |             ^
../src/0.8.33-e9321ff061.clean/src/arvnetwork.c:390:2: error: call to undeclared function 'freeifaddrs'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
  390 |         freeifaddrs (ifap);
      |         ^
2 errors generated.

based on labstreaminglayer/liblsl-Android#4 (unrelated library, just found the error description there) this is caused when using a too-old Android NDK as these methods were implemented more recently (Android NDK 24, see also the source code). is there a way to force the CI to build with a newer android SDK version for this port (though the log file does talk about android-ndk-r27c in the path)?

also, i just got this result on windows in the CI:

-- Performing post-build validation
D:\a\_work\1\s\ports\aravis\portfile.cmake: warning: The following executables were found in ${CURRENT_PACKAGES_DIR}/bin or ${CURRENT_PACKAGES_DIR}/debug/bin. Executables are not valid distribution targets. If these executables are build tools, consider using `vcpkg_copy_tools`. To suppress this message, add set(VCPKG_POLICY_ALLOW_EXES_IN_BIN enabled)
D:\p\aravis_arm64-windows: note: the executables are relative to ${CURRENT_PACKAGES_DIR} here
note: debug/bin/arv-camera-test-0.8.exe
note: debug/bin/arv-fake-gv-camera-0.8.exe
note: debug/bin/arv-test-0.8.exe
note: debug/bin/arv-tool-0.8.exe
note: bin/arv-camera-test-0.8.exe
note: bin/arv-fake-gv-camera-0.8.exe
note: bin/arv-test-0.8.exe
note: bin/arv-tool-0.8.exe

i guess i do need to add a patch for the build after all to skip generating these bins (at least until it's done in upstream)?

@rursprung rursprung requested a review from dg0yt November 25, 2024 19:30
@WangWeiLin-MV WangWeiLin-MV added category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist category:new-port The issue is requesting a new library to be added; consider making a PR! labels Nov 26, 2024
@dg0yt
Copy link
Contributor

dg0yt commented Nov 26, 2024

The Android problem is not the NDK (vcpkg CI has r27c) but the API level (vcpkg uses 21 as default).
For now, you must add the expected fail to scripts/ci.baseline.txt, with a comment similar to the existing ones.
(Changing vcpkg android defaults is #42080.)

@dg0yt
Copy link
Contributor

dg0yt commented Nov 26, 2024

For the executables in bin, the port is expected to call vcpkg_copy_tools. It will move them to tools/<PORT>, and deploy DLLs for windows.

@cenit
Copy link
Contributor

cenit commented Nov 26, 2024

would you mind adding aravis feature to the vcpkg-ci-opencv port, so that it is tested in CI?

@rursprung
Copy link
Author

rursprung commented Nov 26, 2024

it seems that OpenCV doesn't find Aravis on Windows with their detect_aravis.cmake. i'm out of my CMake depth here - any chance that you see the problem here @dg0yt or @cenit?

would you mind adding aravis feature to the vcpkg-ci-opencv port, so that it is tested in CI?

i've added it (as a dedicated entry due to having to add "platform": "!android"); it'll be part of the next push (will wait until i know more about windows; don't want to stress CI too much as it seems to run for hours on end 😮)

@dg0yt
Copy link
Contributor

dg0yt commented Nov 27, 2024

Unfortunately, the CI failure logs weren't uploaded.

@rursprung
Copy link
Author

Unfortunately, the CI failure logs weren't uploaded.

here's the relevant excerpt from vcpkg/buildtrees/opencv4/config-x64-windows-out.log from my local build on windows x64:

-- Verifying WITH_ARAVIS=ON => 'HAVE_ARAVIS_API'=FALSE
CMake Warning at cmake/OpenCVUtils.cmake:785 (message):
  Option WITH_ARAVIS is enabled but corresponding dependency have not been
  found: "HAVE_ARAVIS_API" is FALSE
Call Stack (most recent call first):
  CMakeLists.txt:1974 (ocv_verify_config)

aravis itself was installed successfully (and i can find it in .../vcpkg/packages/aravis_x64-windows):

-- Found Python version '3.12.7 at .../vcpkg/downloads/tools/python/python-3.12.7-x64/python.exe'
-- Using meson: .../vcpkg/downloads/tools/meson-1.6.0-ac58a9/meson.py
Downloading AravisProject-aravis-0.8.33.tar.gz
Successfully downloaded AravisProject-aravis-0.8.33.tar.gz.
-- Extracting source .../vcpkg/downloads/AravisProject-aravis-0.8.33.tar.gz
-- Using source at .../vcpkg/buildtrees/aravis/src/0.8.33-e9321ff061.clean
-- Found external ninja('1.12.1').
-- Using cached msys2-mingw-w64-x86_64-pkgconf-1~2.3.0-1-any.pkg.tar.zst.
-- Using cached msys2-msys2-runtime-3.5.4-2-x86_64.pkg.tar.zst.
-- Using msys root at .../vcpkg/downloads/tools/msys2/21caed2f81ec917b
-- Configuring x64-windows-dbg
-- Getting CMake variables for x64-windows
-- Configuring x64-windows-dbg done
-- Configuring x64-windows-rel
-- Configuring x64-windows-rel done
-- Package x64-windows-dbg
-- Package x64-windows-rel
-- Fixing pkgconfig file: .../vcpkg/packages/aravis_x64-windows/lib/pkgconfig/aravis-0.8.pc
-- Fixing pkgconfig file: .../vcpkg/packages/aravis_x64-windows/debug/lib/pkgconfig/aravis-0.8.pc
-- Installing: .../vcpkg/packages/aravis_x64-windows/share/aravis/copyright
-- Performing post-build validation

@cenit
Copy link
Contributor

cenit commented Nov 27, 2024

i am trying to reproduce it locally on my computer. If I will find any solution, I will ask your permission to push to your vcpkg fork

@cenit
Copy link
Contributor

cenit commented Nov 27, 2024

ok I have a patch. Can I push to your fork? please add me as a contributor to https://github.com/rursprung/vcpkg

image

or add this patch

--- a/modules/videoio/cmake/detect_aravis.cmake
+++ b/modules/videoio/cmake/detect_aravis.cmake
@@ -8,13 +8,14 @@ endif()

 if(NOT HAVE_ARAVIS_API)
   find_path(ARAVIS_INCLUDE "arv.h"
-    PATHS "${ARAVIS_ROOT}" ENV ARAVIS_ROOT
     PATH_SUFFIXES "include/aravis-0.8"
-    NO_DEFAULT_PATH)
+    REQUIRED)
+  find_path(GLIB_INCLUDE "glib-object.h"
+    PATH_SUFFIXES "include/glib-2.0"
+    REQUIRED)
   find_library(ARAVIS_LIBRARY "aravis-0.8"
-    PATHS "${ARAVIS_ROOT}" ENV ARAVIS_ROOT
     PATH_SUFFIXES "lib"
-    NO_DEFAULT_PATH)
+    REQUIRED)
   if(ARAVIS_INCLUDE AND ARAVIS_LIBRARY)
     set(HAVE_ARAVIS_API TRUE)
     file(STRINGS "${ARAVIS_INCLUDE}/arvversion.h" ver_strings REGEX "#define +ARAVIS_(MAJOR|MINOR|MICRO)_VERSION.*")
@@ -23,6 +24,7 @@ if(NOT HAVE_ARAVIS_API)
     string(REGEX REPLACE ".*ARAVIS_MICRO_VERSION[^0-9]+([0-9]+).*" "\\1" ver_micro "${ver_strings}")
     set(ARAVIS_VERSION "${ver_major}.${ver_minor}.${ver_micro}")  # informational
     set(ARAVIS_INCLUDE_DIRS "${ARAVIS_INCLUDE}")
+    list(APPEND ARAVIS_INCLUDE_DIRS "${GLIB_INCLUDE}")
     set(ARAVIS_LIBRARIES "${ARAVIS_LIBRARY}")
   endif()
 endif()

@cenit
Copy link
Contributor

cenit commented Nov 27, 2024

then it complains about missing glibconfig.h
but it is nowhere to be found on the windows glib-2.0
i will explore it better soon

to better speed up the work, please let me be a contributor to your fork so that i can quickly add everything that i find

@rursprung
Copy link
Author

thank you for looking into this! i've added you as a collaborator.

is flagging the dependencies as REQUIRED not interfering with the case when WITH_ARAVIS is not enabled? (i'm not sure if it also calls detect_aravis.cmake in that case or not)

@cenit
Copy link
Contributor

cenit commented Nov 27, 2024

detect_aravis.cmake should be called only if aravis is required. And in that case those findings are required, not optional, so that's the rationale adopted also in other opencv patches

@Sorg-plusplus
Copy link

then it complains about missing glibconfig.h but it is nowhere to be found on the windows glib-2.0 i will explore it better soon

to better speed up the work, please let me be a contributor to your fork so that i can quickly add everything that i find

This patch worked for me:

diff --git a/modules/videoio/cmake/detect_aravis.cmake b/modules/videoio/cmake/detect_aravis.cmake
index cf8429e..4574c87 100644
--- a/modules/videoio/cmake/detect_aravis.cmake
+++ b/modules/videoio/cmake/detect_aravis.cmake
@@ -8,13 +8,17 @@ endif()
 
 if(NOT HAVE_ARAVIS_API)
   find_path(ARAVIS_INCLUDE "arv.h"
-    PATHS "${ARAVIS_ROOT}" ENV ARAVIS_ROOT
     PATH_SUFFIXES "include/aravis-0.8"
-    NO_DEFAULT_PATH)
+    REQUIRED)
+  find_path(GLIB_INCLUDE "glib-object.h"
+    PATH_SUFFIXES "include/glib-2.0"
+    REQUIRED)
+  find_path(GLIB_LIBINC "glibconfig.h"
+    PATH_SUFFIXES "lib/glib-2.0/include"
+    REQUIRED)
   find_library(ARAVIS_LIBRARY "aravis-0.8"
-    PATHS "${ARAVIS_ROOT}" ENV ARAVIS_ROOT
     PATH_SUFFIXES "lib"
-    NO_DEFAULT_PATH)
+    REQUIRED)
   if(ARAVIS_INCLUDE AND ARAVIS_LIBRARY)
     set(HAVE_ARAVIS_API TRUE)
     file(STRINGS "${ARAVIS_INCLUDE}/arvversion.h" ver_strings REGEX "#define +ARAVIS_(MAJOR|MINOR|MICRO)_VERSION.*")
@@ -23,6 +27,7 @@ if(NOT HAVE_ARAVIS_API)
     string(REGEX REPLACE ".*ARAVIS_MICRO_VERSION[^0-9]+([0-9]+).*" "\\1" ver_micro "${ver_strings}")
     set(ARAVIS_VERSION "${ver_major}.${ver_minor}.${ver_micro}")  # informational
     set(ARAVIS_INCLUDE_DIRS "${ARAVIS_INCLUDE}")
+    list(APPEND ARAVIS_INCLUDE_DIRS "${GLIB_INCLUDE}" "${GLIB_LIBINC}")
     set(ARAVIS_LIBRARIES "${ARAVIS_LIBRARY}")
   endif()
 endif()

@cenit
Copy link
Contributor

cenit commented Nov 27, 2024

added the patch so that you know the current state of art. We will need to work on the aravis_libraries list and append missing glib ones to fully fix the link errors

@cenit
Copy link
Contributor

cenit commented Nov 28, 2024

drastically simplified (does not even need a new patch anymore and it builds here)

@rursprung
Copy link
Author

@dg0yt & @cenit: i'd very much appreciate any insight you might have into why the build is broken (see my previous comment) - i lack the experience in this area (and at the moment completely lack time). it'd be great if we could get this working & merged!

@dg0yt
Copy link
Contributor

dg0yt commented Dec 11, 2024

Ah, I forgot to add a note.

The linker line has everything which is need. However, the linux toolchain has what CMake calls a "traditional linker": The order of static libraries matters. But here CMake doesn't provide link libs correctly. We have seen this before, and we don't know the exact triggers :-(
(It is somewhat related to link libs appearing as targets - with explicit depedencies - versus being items in list variables (<Foo>_LIBRARIES) or in lists in target properties (INTERFACE_LINK_LIBRARIES) - implicitly expressing dependencies, but not binding for CMake.

Unfortunately, I can't provide more help ATM.

@cenit
Copy link
Contributor

cenit commented Dec 14, 2024

i have the same error in my opencv PR
Once it will be fixed there and it is accepted, it should disappear also from your PR

@thjordanatlas
Copy link

What is blocking this from being merged to vcpkg? I would be so happy to have this available and thank you all for your great work in this!

@cenit
Copy link
Contributor

cenit commented Jan 28, 2025

This PR depends on #42371

@cenit
Copy link
Contributor

cenit commented Jan 31, 2025

I hope #42371 can be merged soon, so then rebasing this PR on master should fix the error and let also this one come in :)

@cenit
Copy link
Contributor

cenit commented Feb 4, 2025

@rursprung my PR has been merged, i fixed conflicts here, let's hope for a green flag from CI :)

@rursprung
Copy link
Author

@rursprung my PR has been merged, i fixed conflicts here, let's hope for a green flag from CI :)

thanks a lot @cenit! i saw the other PR getting merged (great works, thanks for keeping on it for that long!) and was about to rebase this PR here, but you beat me to it

@cenit
Copy link
Contributor

cenit commented Feb 4, 2025

you can undraft this one, so that if the flag is green it can be accepted asap

@rursprung rursprung marked this pull request as ready for review February 4, 2025 19:23
@rursprung
Copy link
Author

i've marked it ready for review + rebased it due to "This branch must not contain merge commits.". the verify ran through successfully before, so it should be fine now 🤞

note: i do not have access to an aravis-compatible camera anymore (neither USB vision nor GigE vision), so i can't re-test the actual functionality after the rebase! hopefully someone with such a camera could re-test this? (@thjordanatlas: based on your comment you seem to have such a camera since you would like to use this - could you maybe give this PR a try? thanks!)

@AenBleidd
Copy link
Contributor

@rursprung, on behalf of @thjordanatlas:
we can test this but this might take a while (not top priority task for us at the moment), so I'd suggest to move forward and merge this PR.
After we do the test, we will provide feedback and open an issue if there will be something found on our side.

@thjordanatlas
Copy link

Sorry for the late reply, I am busy with other projects, but will try as soon as I can and give feedback. Thank you for work work!

Copy link
Contributor

@WangWeiLin-MV WangWeiLin-MV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port aravis[fast-heartbeat,packet-socket,usb], opencv[aravis] installation tests pass with the following triplets:

  • x64-linux

@WangWeiLin-MV WangWeiLin-MV added the info:reviewed Pull Request changes follow basic guidelines label Feb 13, 2025
Copy link
Member

@BillyONeal BillyONeal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just double check the license? Thanks for the new port!

ports/aravis/vcpkg.json Outdated Show resolved Hide resolved
@WangWeiLin-MV WangWeiLin-MV removed the info:reviewed Pull Request changes follow basic guidelines label Feb 14, 2025
@WangWeiLin-MV
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@dg0yt dg0yt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no gobject-introspection support for the debug build type in vcpkg.

Comment on lines +9 to +10
list(APPEND OPTIONS -Dviewer=disabled)
list(APPEND OPTIONS -Dgst-plugin=disabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
list(APPEND OPTIONS -Dviewer=disabled)
list(APPEND OPTIONS -Dgst-plugin=disabled)
set(OPTIONS "")
set(OPTIONS_RELEASE "")

list(APPEND OPTIONS -Dfast-heartbeat=false)
endif()
if("introspection" IN_LIST FEATURES)
list(APPEND OPTIONS -Dintrospection=enabled)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
list(APPEND OPTIONS -Dintrospection=enabled)
list(APPEND OPTIONS_RELEASE -Dintrospection=enabled)
else
list(APPEND OPTIONS_RELEASE -Dintrospection=disabled)

SOURCE_PATH
"${SOURCE_PATH}"
OPTIONS
${OPTIONS}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
${OPTIONS}
${OPTIONS}
-Dviewer=disabled
-Dgst-plugin=disabled
OPTIONS_RELEASE
${OPTIONS_RELEASE}
OPTIONS_DEBUG
-Dintrospection=disabled

list(APPEND OPTIONS -Dintrospection=enabled)
endif()

set(GLIB_TOOLS_DIR "${CURRENT_HOST_INSTALLED_DIR}/tools/glib")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(GLIB_TOOLS_DIR "${CURRENT_HOST_INSTALLED_DIR}/tools/glib")
set(GLIB_TOOLS_DIR "${CURRENT_HOST_INSTALLED_DIR}/tools/glib")
set(GIR_TOOLS_DIR "${CURRENT_HOST_INSTALLED_DIR}/tools/gobject-introspection")
if(CMAKE_HOST_WIN32 AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x86")
set(GIR_TOOLS_DIR "${CURRENT_INSTALLED_DIR}/tools/gobject-introspection")
endif()

${OPTIONS}
ADDITIONAL_BINARIES
"glib-mkenums='${GLIB_TOOLS_DIR}/glib-mkenums'"
"glib-compile-resources='${GLIB_TOOLS_DIR}/glib-compile-resources${VCPKG_HOST_EXECUTABLE_SUFFIX}'"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"glib-compile-resources='${GLIB_TOOLS_DIR}/glib-compile-resources${VCPKG_HOST_EXECUTABLE_SUFFIX}'"
"glib-compile-resources='${GLIB_TOOLS_DIR}/glib-compile-resources${VCPKG_HOST_EXECUTABLE_SUFFIX}'"
"g-ir-compiler='${GIR_TOOLS_DIR}/g-ir-compiler${VCPKG_HOST_EXECUTABLE_SUFFIX}'"
"g-ir-scanner='${GIR_TOOLS_DIR}/g-ir-scanner'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:new-port The issue is requesting a new library to be added; consider making a PR! category:port-feature The issue is with a library, which is requesting new capabilities that didn’t exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[New Port Request] aravis Add aravis library
9 participants