Is there a port of OpenCV 3.x for FreeBSD

Hi all,
I am a newbie of FreeBSD. I am searching for a port of OpenCV 3.0 or 3.1 for FreeBSD. I only find OpenCV 2.4.
If there is no port, how could I create a port for it?

Thanks,
Thuan
 
Well, I could build opencv 3.1 by myself without any modification. So, I think the reason of no port of opencv is that we could build it ourselves.
 
Well, I could build opencv 3.1 by myself without any modification. So, I think the reason of no port of opencv is that we could build it ourselves.

Hi Leo5th, I was trying to install but i got this error and I can't resolve, you can help me?
Code:
% make
[  8%] Built target opencv_core
[ 18%] Built target opencv_imgproc
[ 21%] Built target opencv_imgcodecs
Scanning dependencies of target opencv_videoio
[ 21%] Building CXX object modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_libv4l.cpp.o
/usr/local/home/staff/rizzo/tmp/opencv-3.1.0/modules/videoio/src/cap_libv4l.cpp:257:10: fatal error:
  'asm/types.h' file not found
#include <asm/types.h>  /* for videodev2.h */
  ^
1 error generated.
I found this file in

/usr/src/sys/compat/linuxkpi/common/include/asm/types.h

But when I try to use this some other error appear, when I see a types.h code have a #define _KERNEL to create the define types s{8,16,32,64} and __s{8,16,32,64}.
I was stop because I have make many change in the code.

My system is FreeBSD 11.0 (-current) yet, last update was in December.
 
Don't use /usr/src/sys/compat/linuxkpi/common/include/asm/types.h. This is for some kernel modules only.

The correct headers needed to compile software that uses V4L are in multimedia/v4l_compat. The asm/types.h include line would likely need to be removed as well. This is just a guess but it's what the current graphics/opencv port does too.
 
Don't use /usr/src/sys/compat/linuxkpi/common/include/asm/types.h. This is for some kernel modules only.

The correct headers needed to compile software that uses V4L are in multimedia/v4l_compat. The asm/types.h include line would likely need to be removed as well. This is just a guess but it's what the current graphics/opencv port does too.


My box:
Code:
# uname -a
FreeBSD venus 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r293243: Thu Jan  7 00:51:45 BRST 2016  root@venus:/usr/obj/usr/src/sys/VENUS  amd64
the multimedia/v4l_compat already installed, but I can't found any other types.h

Solution was turn off the videoio in CMakeCache.txt

I'm not found the correct types.h to be use
Code:
root@venus: # pkg info -a | grep -i v4
gstreamer1-plugins-v4l2-1.6.2  GStreamer Video 4 Linux 2 source plugin
libv4l-1.6.3_1  Video4Linux library
p5-IO-Socket-IP-0.37  Drop-in replacement for IO::Socket::INET supporting IPv4 and IPv6
v4l-utils-1.6.3  Video4Linux utilities
v4l_compat-1.6.3  Video4Linux IOCTL header files

root@venus: # find  /usr/ -name types.h
/usr/include/rpc/types.h
/usr/include/sys/types.h
/usr/local/home/staff/rizzo/tmp/opencv-3.1.0/3rdparty/libwebp/webp/types.h
/usr/local/include/zzip/types.h
/usr/local/include/kpathsea/types.h
/usr/local/include/sp/types.h
/usr/local/include/webp/types.h
/usr/local/include/mutter/meta/types.h
/usr/local/include/cdio/types.h
/usr/local/include/libwmf/types.h
/usr/local/include/graphviz/types.h
/usr/local/include/libgltf-0.0/types.h
/usr/local/include/libcmis-c-0.5/libcmis-c/types.h
/usr/local/include/libopenraw-1.0/libopenraw/types.h
/usr/local/include/git2/types.h
/usr/local/include/cairomm-1.0/cairomm/types.h
/usr/local/include/pangomm-1.4/pangomm/types.h
/usr/local/include/gdkmm-3.0/gdkmm/types.h
/usr/local/include/libvcd/types.h
/usr/local/include/freerdp/types.h
/usr/local/include/wx-3.0/wx/types.h
/usr/local/include/wine/msvcrt/sys/types.h
/usr/local/include/gdkmm-2.4/gdkmm/types.h
/usr/local/include/ntfs-3g/types.h
/usr/local/include/jack/types.h
/usr/local/lib/gcc48/gcc/x86_64-portbld-freebsd11.0/4.8.5/include-fixed/sys/types.h
/usr/local/lib/gcc48/include/c++/parallel/types.h
/usr/local/lib/gcc47/gcc/x86_64-portbld-freebsd11.0/4.7.4/include-fixed/sys/types.h
/usr/local/lib/gcc47/include/c++/parallel/types.h
/usr/local/sage-6.7/local/include/c++/4.9.2/parallel/types.h
/usr/local/sage-6.7/local/lib/gcc/x86_64-unknown-freebsd11.0/4.9.2/include-fixed/sys/types.h
/usr/src/sys/dev/isci/types.h
/usr/src/sys/compat/linuxkpi/common/include/linux/types.h
/usr/src/sys/compat/linuxkpi/common/include/asm/types.h
/usr/src/sys/sys/types.h
/usr/src/sys/cddl/compat/opensolaris/sys/types.h
/usr/src/sys/rpc/types.h
/usr/src/contrib/ofed/include/infiniband/types.h
/usr/src/contrib/sendmail/include/sm/types.h
/usr/src/contrib/ntp/lib/isc/include/isc/types.h
/usr/src/contrib/telnet/telnet/types.h
/usr/src/crypto/heimdal/appl/telnet/telnet/types.h
root@venus: #
 
Sorry for being too vague in my previous post. I tried compiling OpenCV 3.1 myself now. You don't need asm/types.h on FreeBSD. Remove it. In patch form:
Code:
--- modules/videoio/src/cap_libv4l.cpp.orig	2016-07-08 20:08:26.339767464 +0200
+++ modules/videoio/src/cap_libv4l.cpp	2016-07-08 20:08:36.630757601 +0200
@@ -251,7 +251,6 @@
 #include <sys/mman.h>
 #include <string.h>
 #include <stdlib.h>
-#include <asm/types.h>          /* for videodev2.h */
 #include <assert.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
There is also an issue with malloc.h:
Code:
--- modules/imgcodecs/src/rgbe.cpp.orig	2016-07-08 20:24:21.567695506 +0200
+++ modules/imgcodecs/src/rgbe.cpp	2016-07-08 20:24:41.556701536 +0200
@@ -44,7 +44,7 @@
 #include "rgbe.hpp"
 #include <math.h>
 #if !defined(__APPLE__)
-#include <malloc.h>
+#include <stdlib.h>
 #endif
 #include <string.h>
 #include <ctype.h>
To build OpenCV 3.1 with videoio:
  1. Apply above patches
  2. cmake -DCMAKE_REQUIRED_INCLUDES:STRING="/usr/local/include"
  3. make -j6
I haven't tried to use it yet, but at least it compiles fine on FreeBSD 10.3/amd64.
 
When I use the above patches and cmake command on the OpenCV 3.1 source, I get back an error early in the build which reports a missing header: sys/videoio.h

Anyone know which port this header belongs in?
 
I do have the v4l_compat and lib4l ports installed. Also confirmed the proper include file is located in /usr/local/include/linux

I think my issue is OpenCV's configure process is not finding the files include /usr/local/include/linux, just its parent directory. Is there a flag I can pass to include additional directories of head files?
 
Last edited by a moderator:
I think my issue is OpenCV's configure process is not finding the files include /usr/local/include/linux, just its parent directory. Is there a flag I can pass to include additional directories of head files?
That's what the -DCMAKE_REQUIRED_INCLUDES:STRING="/usr/local/include" flag does for me. If I don't add it cmake doesn't find any V4L related headers.
 
Back
Top