Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: NetBSD 10 and opencv-3.4.17 pkg crash



I found a workaround.

First, I'm also seeing this with the latest binary packages:
opencv-3.4.20nb2. Similar stack trace in the core dump as the previous
package version.

I then tried to build and install from pkgsrc/graphics/opencv, and see the
same issue. There seems to be a problem with how the opencv package is
built on Aarch64.

What I did get to work is the latest OpenCV 4.x (4.10.0-pre) source from
https://github.com/opencv/opencv. I was able to (patiently) build on my
Pinebook Pro with NetBSD 10. Below is the git diff.

To test, I ran the samples/python/video.py and it worked -- sure enough,
it successfully displayed the Pinebook Pro's built in video cam. I have a
simple frame capture test below that works too.

Cool.

If I can get the samples and tests to pass (still experimenting), would
this be worth my effort to integrate into pkgsrc?

Thanks - Joel

Here's a simple frame capture test:
import cv2

cam = cv2.VideoCapture('/dev/video0')
print((cam.get(cv2.CAP_PROP_FRAME_WIDTH),cam.get(cv2.CAP_PROP_FRAME_HEIGHT)))
ret, frame = cam.read()
if ret:
    cv2.imwrite('/tmp/snap.jpeg', frame)
else:
    print("Camera read failed.")
cam.release()

Here's the git diff:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 136de5c79f..d6cc1e6480 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,6 +5,13 @@
 #      $ cmake <PATH_TO_OPENCV_ROOT>
 #
 #
----------------------------------------------------------------------------
+
+# BSD
+add_compile_options($<$<COMPILE_LANGUAGE:C>:-std=gnu99>)
+add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=gnu++20>)
+add_definitions(-D__OpenBSD__)
+#
+
 # Disable in-source builds to prevent source tree corruption.
 if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
   message(FATAL_ERROR "
@@ -143,7 +150,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)  #
https://cmake.org/cmake/help/
     if(WIN32)
       set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH
"Installation Directory" FORCE)
     else()
-      set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation
Directory" FORCE)
+      set(CMAKE_INSTALL_PREFIX "/usr/pkg" CACHE PATH "Installation
Directory" FORCE)
     endif()
   else()
     # any cross-compiling
@@ -706,9 +713,9 @@ if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
           message(STATUS "CUDA: Not detected, for stand alone
installations the path to the CUDA toolkit should be manually
specified with -DCUDA_PATH=. e.g. -DCUDA_PATH=\"C:/Program
Files/NVIDIA GPU Computing Toolkit/CUDA/vXX.X\"")
         endif()
       elseif(UNIX)
-        message(STATUS "CUDA: Not detected, make sure you have performed
the mandatory Post-installation actions described in the CUDA installation
guide.\n   For stand alone installations you can set the CUDA_PATH
environmental or CMake variable. e.g. export
CUDA_PATH=/usr/local/cuda-XX.X or -DCUDA_PATH=/usr/local/cuda-XX.X.")
-        message(STATUS "CUDA: Falling back to searching for the CUDA
compiler in its default location (/usr/local/cuda)")
-        set(CUDA_PATH "/usr/local/cuda" CACHE INTERNAL "")
+        message(STATUS "CUDA: Not detected, make sure you have performed
the mandatory Post-installation actions described in the CUDA installation
guide.\n   For stand alone installations you can set the CUDA_PATH
environmental or CMake variable. e.g. export CUDA_PATH=/usr/pkg/cuda-XX.X
or -DCUDA_PATH=/usr/pkg/cuda-XX.X.")
+        message(STATUS "CUDA: Falling back to searching for the CUDA
compiler in its default location (/usr/pkg/cuda)")
+        set(CUDA_PATH "/usr/pkg/cuda" CACHE INTERNAL "")
         set(ENV{CUDA_PATH} ${CUDA_PATH})
         unset(CMAKE_CUDA_COMPILER CACHE)
         unset(CMAKE_CUDA_COMPILER)
@@ -720,7 +727,7 @@ if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
     if(CMAKE_CUDA_COMPILER)
       enable_language(CUDA)
     elseif(UNIX)
-      message(WARNING "CUDA: Not detected!  If you are not using the
default host compile
+add_compile_options($<$<COMPILE_LANGUAGE:C>:-std=gnu99>)
+add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-std=gnu++20>)
+add_definitions(-D__OpenBSD__)
+#
+
 # Disable in-source builds to prevent source tree corruption.
 if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
   message(FATAL_ERROR "
@@ -143,7 +150,7 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)  #
https://cmake.org/cmake/help/
     if(WIN32)
       set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH
"Installation Directory" FORCE)
     else()
-      set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation
Directory" FORCE)
+      set(CMAKE_INSTALL_PREFIX "/usr/pkg" CACHE PATH "Installation
Directory" FORCE)
     endif()
   else()
     # any cross-compiling
@@ -706,9 +713,9 @@ if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
           message(STATUS "CUDA: Not detected, for stand alone
installations the path to the CUDA toolkit should be manually
specified with -DCUDA_PATH=. e.g. -DCUDA_PATH=\"C:/Program
Files/NVIDIA GPU Computing Toolkit/CUDA/vXX.X\"")
         endif()
       elseif(UNIX)
-        message(STATUS "CUDA: Not detected, make sure you have performed
the mandatory Post-installation actions described in the CUDA installation
guide.\n   For stand alone installations you can set the CUDA_PATH
environmental or CMake variable. e.g. export
CUDA_PATH=/usr/local/cuda-XX.X or -DCUDA_PATH=/usr/local/cuda-XX.X.")
-        message(STATUS "CUDA: Falling back to searching for the CUDA
compiler in its default location (/usr/local/cuda)")
-        set(CUDA_PATH "/usr/local/cuda" CACHE INTERNAL "")
+        message(STATUS "CUDA: Not detected, make sure you have performed
the mandatory Post-installation actions described in the CUDA installation
guide.\n   For stand alone installations you can set the CUDA_PATH
environmental or CMake variable. e.g. export CUDA_PATH=/usr/pkg/cuda-XX.X
or -DCUDA_PATH=/usr/pkg/cuda-XX.X.")
+        message(STATUS "CUDA: Falling back to searching for the CUDA
compiler in its default location (/usr/pkg/cuda)")
+        set(CUDA_PATH "/usr/pkg/cuda" CACHE INTERNAL "")
         set(ENV{CUDA_PATH} ${CUDA_PATH})
         unset(CMAKE_CUDA_COMPILER CACHE)
         unset(CMAKE_CUDA_COMPILER)
@@ -720,7 +727,7 @@ if(ENABLE_CUDA_FIRST_CLASS_LANGUAGE)
     if(CMAKE_CUDA_COMPILER)
       enable_language(CUDA)
     elseif(UNIX)
-      message(WARNING "CUDA: Not detected!  If you are not using the
default host compiler (g++) then you need to specify both
CMAKE_CUDA_HOST_COMPILER and CMAKE_CUDA_COMPILER. e.g.
-DCMAKE_CUDA_HOST_COMPILER=/usr/bin/clang++
-DCMAKE_CUDA_COMPILER=/usr/local/cuda/bin/nvcc.")
+      message(WARNING "CUDA: Not detected!  If you are not using the
default host compiler (g++) then you need to specify both
CMAKE_CUDA_HOST_COMPILER and CMAKE_CUDA_COMPILER. e.g.
-DCMAKE_CUDA_HOST_COMPILER=/usr/bin/clang++
-DCMAKE_CUDA_COMPILER=/usr/pkg/cuda/bin/nvcc.")
     endif()
   endif()
 endif()




Home | Main Index | Thread Index | Old Index