UrielCh / opencv4nodejs

ESM Nodejs bindings to OpenCV 3/4
MIT License
256 stars 51 forks source link

Raspberry Pi / debian prebuilt libopencv-dev (4.5.1) not compatible. #67

Open btsimonh opened 1 year ago

btsimonh commented 1 year ago

This is just a note that if trying to install on RPi Bullseye, the version of opencv installed using

sudo apt install libopencv-dev

is 4.5.1 (as of 2023/01/10), and is known to break many apps building against it...

Error Message

In file included from ../cc/tracking/tracking.cc:6:
../cc/tracking/./Trackers/TrackerBoosting.h:11:14: error: ‘TrackerBoosting’ is not a member of ‘cv’; did you mean ‘TrackerBoosting’?
   11 |  cv::Ptr<cv::TrackerBoosting> tracker;
 (+++ a long list of related errors)
ERR! install make: *** [opencv4nodejs.target.mk:257: Release/obj.target/opencv4nodejs/cc/tracking/tracking.o] Error 1

OpenCV version (example 3.4.1): 4.5.1

With OpenCV-contrib? (extra modules): ?

OS: Windows 7 / 8 / 10? / MacOSX? / Ubuntu? raspian Bullseye on rpi3b

I'll now triple check my PSU and start a build from source :). br, Simon

UrielCh commented 1 year ago

le me plug a Pi4B I used to build is on Raspberry Pi from source.

 sudo apt install libopencv-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  gdal-data libaec0 libarmadillo10 libarpack2 libavcodec-dev libavformat-dev libavutil-dev libcfitsio9 libcharls2 libdap27 libdapclient6v5 libdc1394-dev libdeflate-dev libepsilon1 libexif-dev libexif-doc
  libfreexl1 libfyba0 libgdal28 libgdcm-dev libgdcm3.0 libgeos-3.9.0 libgeos-c1v5 libgeotiff5 libgl2ps1.4 libglew2.1 libgphoto2-dev libhdf4-0-alt libhdf5-103-1 libhdf5-hl-100 libheif1 libilmbase-dev
  libjbig-dev libjpeg-dev libjpeg62-turbo-dev libjsoncpp24 libkmlbase1 libkmldom1 libkmlengine1 liblept5 liblzma-dev libmariadb3 libminizip1 libnetcdf18 libodbc1 libogdi4.1 libopencv-calib3d-dev
  libopencv-calib3d4.5 libopencv-contrib-dev libopencv-contrib4.5 libopencv-core-dev libopencv-core4.5 libopencv-dnn-dev libopencv-dnn4.5 libopencv-features2d-dev libopencv-features2d4.5
  libopencv-flann-dev libopencv-flann4.5 libopencv-highgui-dev libopencv-highgui4.5 libopencv-imgcodecs-dev libopencv-imgcodecs4.5 libopencv-imgproc-dev libopencv-imgproc4.5 libopencv-ml-dev
  libopencv-ml4.5 libopencv-objdetect-dev libopencv-objdetect4.5 libopencv-photo-dev libopencv-photo4.5 libopencv-shape-dev libopencv-shape4.5 libopencv-stitching-dev libopencv-stitching4.5
  libopencv-superres-dev libopencv-superres4.5 libopencv-video-dev libopencv-video4.5 libopencv-videoio-dev libopencv-videoio4.5 libopencv-videostab-dev libopencv-videostab4.5 libopencv-viz-dev
  libopencv-viz4.5 libopencv4.5-java libopencv4.5-jni libopenexr-dev libopengl0 libpq5 libproj19 libprotobuf23 libqhull8.0 libraw1394-dev libraw1394-tools librttopo1 libsocket++1 libspatialite7 libsuperlu5
  libswresample-dev libswscale-dev libsz2 libtbb-dev libtbb2 libtesseract4 libtiff-dev libtiffxx5 liburiparser1 libvtk9 libxerces-c3.2 mariadb-common mysql-common odbcinst odbcinst1debian2 opencv-data
  proj-bin proj-data
Suggested packages:
  geotiff-bin gdal-bin libgeotiff-epsg glew-utils libhdf4-doc libhdf4-alt-dev hdf4-tools liblzma-doc libmyodbc odbc-postgresql tdsodbc unixodbc-bin ogdi-bin opencv-doc libraw1394-doc libtbb-doc
  mpi-default-bin vtk9-doc vtk9-examples
The following NEW packages will be installed:
  gdal-data libaec0 libarmadillo10 libarpack2 libavcodec-dev libavformat-dev libavutil-dev libcfitsio9 libcharls2 libdap27 libdapclient6v5 libdc1394-dev libdeflate-dev libepsilon1 libexif-dev libexif-doc
  libfreexl1 libfyba0 libgdal28 libgdcm-dev libgdcm3.0 libgeos-3.9.0 libgeos-c1v5 libgeotiff5 libgl2ps1.4 libglew2.1 libgphoto2-dev libhdf4-0-alt libhdf5-103-1 libhdf5-hl-100 libheif1 libilmbase-dev
  libjbig-dev libjpeg-dev libjpeg62-turbo-dev libjsoncpp24 libkmlbase1 libkmldom1 libkmlengine1 liblept5 liblzma-dev libmariadb3 libminizip1 libnetcdf18 libodbc1 libogdi4.1 libopencv-calib3d-dev
  libopencv-calib3d4.5 libopencv-contrib-dev libopencv-contrib4.5 libopencv-core-dev libopencv-core4.5 libopencv-dev libopencv-dnn-dev libopencv-dnn4.5 libopencv-features2d-dev libopencv-features2d4.5
  libopencv-flann-dev libopencv-flann4.5 libopencv-highgui-dev libopencv-highgui4.5 libopencv-imgcodecs-dev libopencv-imgcodecs4.5 libopencv-imgproc-dev libopencv-imgproc4.5 libopencv-ml-dev
  libopencv-ml4.5 libopencv-objdetect-dev libopencv-objdetect4.5 libopencv-photo-dev libopencv-photo4.5 libopencv-shape-dev libopencv-shape4.5 libopencv-stitching-dev libopencv-stitching4.5
  libopencv-superres-dev libopencv-superres4.5 libopencv-video-dev libopencv-video4.5 libopencv-videoio-dev libopencv-videoio4.5 libopencv-videostab-dev libopencv-videostab4.5 libopencv-viz-dev
  libopencv-viz4.5 libopencv4.5-java libopencv4.5-jni libopenexr-dev libopengl0 libpq5 libproj19 libprotobuf23 libqhull8.0 libraw1394-dev libraw1394-tools librttopo1 libsocket++1 libspatialite7 libsuperlu5
  libswresample-dev libswscale-dev libsz2 libtbb-dev libtbb2 libtesseract4 libtiff-dev libtiffxx5 liburiparser1 libvtk9 libxerces-c3.2 mariadb-common mysql-common odbcinst odbcinst1debian2 opencv-data
  proj-bin proj-data
0 upgraded, 117 newly installed, 0 to remove and 0 not upgraded.
Need to get 74.0 MB of archives.
After this operation, 337 MB of additional disk space will be used.
Do you want to continue? [Y/n]

outch

node --version
v18.12.1

mkdir testcv
cd testcv/
npm init -y
export OPENCV4NODEJS_DISABLE_AUTOBUILD=1
time npm install @u4/opencv4nodejs  --loglevel verbose

I only get little logs, but a top shows me 4 cc1plus I'm so proud of these 4 little cores.

real 7m48.545s user 27m47.059s sys 2m9.989s

UrielCh commented 1 year ago

after a call to npx build-opencv build see that tracking is not present in the raspberry pi prebuilt version.

opencv_version
4.5.1
UrielCh commented 1 year ago

next try:

export OPENCV_BUILD_ROOT=~/opencv &&
export OPENCV4NODEJS_DISABLE_AUTOBUILD=0 &&
time npx build-opencv --version=4.6.0 rebuild

failed /bin/sh: 1: cmake: not found

sudo apt install cmake

try again:

time npx build-opencv --version=4.6.0 rebuild
...
  SOLINK_MODULE(target) Release/obj.target/opencv4nodejs.node
  COPY Release/opencv4nodejs.node
make: Leaving directory '.../testcv/node_modules/@u4/opencv4nodejs/build'
gyp info ok
info install node-gyp complete successfully

real    57m8.395s
user    194m37.022s
sys     13m27.879s
UrielCh commented 1 year ago

wget https://github.com/UrielCh/opencv4nodejs/raw/master/data/Lenna.png nano index.mjs

import cv from '@u4/opencv4nodejs';
import {resolve} from 'path';

export async function applyColorMap() {
    const file = resolve('Lenna.png');
    console.log('loading ', file);
    const image = cv.imread(file);
    console.log('Lenna.png loaded');
    const processedImage = cv.applyColorMap(image, cv.COLORMAP_AUTUMN);
    cv.imwrite(resolve('Lenna2.png'), processedImage);
    console.log('done');
}
applyColorMap();

Works.

UrielCh commented 1 year ago

raspberry default modules flags: opencv_modules.hpp

/*
 *      ** File generated automatically, do not modify **
 *
 * This file defines the list of modules available in current build configuration
 *
 *
*/

// This definition means that OpenCV is built with enabled non-free code.
// For example, patented algorithms for non-profit/non-commercial use only.
/* #undef OPENCV_ENABLE_NONFREE */

#define HAVE_OPENCV_ALPHAMAT
#define HAVE_OPENCV_ARUCO
#define HAVE_OPENCV_BGSEGM
#define HAVE_OPENCV_BIOINSPIRED
#define HAVE_OPENCV_CALIB3D
#define HAVE_OPENCV_CCALIB
#define HAVE_OPENCV_CORE
#define HAVE_OPENCV_DATASETS
#define HAVE_OPENCV_DNN
#define HAVE_OPENCV_DNN_OBJDETECT
#define HAVE_OPENCV_DNN_SUPERRES
#define HAVE_OPENCV_DPM
#define HAVE_OPENCV_FACE
#define HAVE_OPENCV_FEATURES2D
#define HAVE_OPENCV_FLANN
#define HAVE_OPENCV_FREETYPE
#define HAVE_OPENCV_FUZZY
#define HAVE_OPENCV_HDF
#define HAVE_OPENCV_HFS
#define HAVE_OPENCV_HIGHGUI
#define HAVE_OPENCV_IMG_HASH
#define HAVE_OPENCV_IMGCODECS
#define HAVE_OPENCV_IMGPROC
#define HAVE_OPENCV_INTENSITY_TRANSFORM
#define HAVE_OPENCV_LINE_DESCRIPTOR
#define HAVE_OPENCV_MCC
#define HAVE_OPENCV_ML
#define HAVE_OPENCV_OBJDETECT
#define HAVE_OPENCV_OPTFLOW
#define HAVE_OPENCV_PHASE_UNWRAPPING
#define HAVE_OPENCV_PHOTO
#define HAVE_OPENCV_PLOT
#define HAVE_OPENCV_QUALITY
#define HAVE_OPENCV_RAPID
#define HAVE_OPENCV_REG
#define HAVE_OPENCV_RGBD
#define HAVE_OPENCV_SALIENCY
#define HAVE_OPENCV_SHAPE
#define HAVE_OPENCV_STEREO
#define HAVE_OPENCV_STITCHING
#define HAVE_OPENCV_STRUCTURED_LIGHT
#define HAVE_OPENCV_SUPERRES
#define HAVE_OPENCV_SURFACE_MATCHING
#define HAVE_OPENCV_TEXT
#define HAVE_OPENCV_TRACKING
#define HAVE_OPENCV_VIDEO
#define HAVE_OPENCV_VIDEOIO
#define HAVE_OPENCV_VIDEOSTAB
#define HAVE_OPENCV_VIZ
#define HAVE_OPENCV_XIMGPROC
#define HAVE_OPENCV_XOBJDETECT
#define HAVE_OPENCV_XPHOTO
UrielCh commented 1 year ago

the errors:

ERR! install In file included from /usr/include/opencv4/opencv2/ml.hpp:1951,
ERR! install                  from ../cc/machinelearning/machinelearning.h:3,
ERR! install                  from ../cc/opencv4nodejs.cc:29:
ERR! install /usr/include/opencv4/opencv2/ml/ml.inl.hpp: In function ‘int cv::ml::simulatedAnnealingSolver(SimulatedAnnealingSolverSystem&, double, double, double, size_t, double*, cv::RNG&)’:
ERR! install /usr/include/opencv4/opencv2/ml/ml.inl.hpp:55: note: ‘-Wmisleading-indentation’ is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
ERR! install    55 |     return exchange;
ERR! install In file included from ../cc/tracking/tracking.cc:6:
ERR! install ../cc/tracking/./Trackers/TrackerBoosting.h:11:14: error: ‘TrackerBoosting’ is not a member of ‘cv’; did you mean ‘TrackerBoosting’?
ERR! install    11 |  cv::Ptr<cv::TrackerBoosting> tracker;
ERR! install       |              ^~~~~~~~~~~~~~~
ERR! install ../cc/tracking/./Trackers/TrackerBoosting.h:6:7: note: ‘TrackerBoosting’ declared here
ERR! install     6 | class TrackerBoosting : public Tracker {
ERR! install       |       ^~~~~~~~~~~~~~~
ERR! install ../cc/tracking/./Trackers/TrackerBoosting.h:11:29: error: template argument 1 is invalid
ERR! install    11 |  cv::Ptr<cv::TrackerBoosting> tracker;
ERR! install       |                             ^
ERR! install ../cc/tracking/./Trackers/TrackerBoosting.h: In member function ‘virtual cv::Ptr<cv::Tracker> TrackerBoosting::getTracker()’:
ERR! install ../cc/tracking/./Trackers/TrackerBoosting.h:24:10: error: could not convert ‘((TrackerBoosting*)this)->TrackerBoosting::tracker’ from ‘int’ to ‘cv::Ptr<cv::Tracker>’
ERR! install    24 |   return tracker;
ERR! install       |          ^~~~~~~
ERR! install       |          |
ERR! install       |          int
ERR! install In file included from ../cc/tracking/tracking.cc:7:
ERR! install ../cc/tracking/./Trackers/TrackerMedianFlow.h: At global scope:
ERR! install ../cc/tracking/./Trackers/TrackerMedianFlow.h:11:14: error: ‘TrackerMedianFlow’ is not a member of ‘cv’; did you mean ‘TrackerMedianFlow’?
ERR! install    11 |  cv::Ptr<cv::TrackerMedianFlow> tracker;
ERR! install       |              ^~~~~~~~~~~~~~~~~
ERR! install ../cc/tracking/./Trackers/TrackerMedianFlow.h:6:7: note: ‘TrackerMedianFlow’ declared here
ERR! install     6 | class TrackerMedianFlow : public Tracker {
ERR! install       |       ^~~~~~~~~~~~~~~~~
ERR! install ../cc/tracking/./Trackers/TrackerMedianFlow.h:11:31: error: template argument 1 is invalid
ERR! install    11 |  cv::Ptr<cv::TrackerMedianFlow> tracker;
ERR! install       |                               ^
ERR! install ../cc/tracking/./Trackers/TrackerMedianFlow.h: In member function ‘virtual cv::Ptr<cv::Tracker> TrackerMedianFlow::getTracker()’:
ERR! install ../cc/tracking/./Trackers/TrackerMedianFlow.h:24:10: error: could not convert ‘((TrackerMedianFlow*)this)->TrackerMedianFlow::tracker’ from ‘int’ to ‘cv::Ptr<cv::Tracker>’
ERR! install    24 |   return tracker;
ERR! install       |          ^~~~~~~
ERR! install       |          |
ERR! install       |          int
ERR! install ../cc/tracking/./Trackers/TrackerTLD.h: At global scope:
ERR! install ../cc/tracking/./Trackers/TrackerTLD.h:11:14: error: ‘TrackerTLD’ is not a member of ‘cv’; did you mean ‘TrackerMIL’?
ERR! install    11 |  cv::Ptr<cv::TrackerTLD> tracker;
ERR! install       |              ^~~~~~~~~~
ERR! install       |              TrackerMIL
ERR! install ../cc/tracking/./Trackers/TrackerTLD.h:11:24: error: template argument 1 is invalid
ERR! install    11 |  cv::Ptr<cv::TrackerTLD> tracker;
ERR! install       |                        ^
ERR! install ../cc/tracking/./Trackers/TrackerTLD.h: In member function ‘virtual cv::Ptr<cv::Tracker> TrackerTLD::getTracker()’:
ERR! install ../cc/tracking/./Trackers/TrackerTLD.h:24:10: error: could not convert ‘((TrackerTLD*)this)->TrackerTLD::tracker’ from ‘int’ to ‘cv::Ptr<cv::Tracker>’
ERR! install    24 |   return tracker;
ERR! install       |          ^~~~~~~
ERR! install       |          |
ERR! install       |          int
ERR! install In file included from ../cc/tracking/tracking.cc:13:
ERR! install ../cc/tracking/MultiTracker.h: At global scope:
ERR! install ../cc/tracking/MultiTracker.h:17:70: error: ‘MultiTracker’ is not a member of ‘cv’; did you mean ‘MultiTracker’?
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |                                                                      ^~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.h:17:7: note: ‘MultiTracker’ declared here
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |       ^~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.h:17:70: error: template argument 1 is invalid
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |                                                                      ^~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.h:17:82: error: template argument 2 is invalid
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |                                                                                  ^~
ERR! install In file included from ../cc/tracking/tracking.cc:21:
ERR! install ../cc/tracking/./Trackers/TrackerMOSSE.h:13:14: error: ‘TrackerMOSSE’ is not a member of ‘cv’; did you mean ‘TrackerMIL’?
ERR! install    13 |  cv::Ptr<cv::TrackerMOSSE> tracker;
ERR! install       |              ^~~~~~~~~~~~
ERR! install       |              TrackerMIL
ERR! install ../cc/tracking/./Trackers/TrackerMOSSE.h:13:26: error: template argument 1 is invalid
ERR! install    13 |  cv::Ptr<cv::TrackerMOSSE> tracker;
ERR! install       |                          ^
ERR! install ../cc/tracking/./Trackers/TrackerMOSSE.h: In member function ‘virtual cv::Ptr<cv::Tracker> TrackerMOSSE::getTracker()’:
ERR! install ../cc/tracking/./Trackers/TrackerMOSSE.h:26:10: error: could not convert ‘((TrackerMOSSE*)this)->TrackerMOSSE::tracker’ from ‘int’ to ‘cv::Ptr<cv::Tracker>’
ERR! install    26 |   return tracker;
ERR! install       |          ^~~~~~~
ERR! install       |          |
ERR! install       |          int
ERR! install ../cc/tracking/Tracker.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Tracker::Clear(Nan::NAN_METHOD_ARGS_TYPE)’:
ERR! install ../cc/tracking/Tracker.cc:15:43: error: ‘class cv::Tracker’ has no member named ‘clear’
ERR! install    15 |  Tracker::unwrapThis(info)->getTracker()->clear();
ERR! install       |                                           ^~~~~
ERR! install ../cc/tracking/Tracker.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Tracker::Init(Nan::NAN_METHOD_ARGS_TYPE)’:
ERR! install ../cc/tracking/Tracker.cc:29:58: error: void value not ignored as it ought to be
ERR! install    29 |  bool ret = Tracker::unwrapThis(info)->getTracker()->init(image, boundingBox);
ERR! install       |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
ERR! install ../cc/tracking/Tracker.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE Tracker::Update(Nan::NAN_METHOD_ARGS_TYPE)’:
ERR! install ../cc/tracking/Tracker.cc:44:64: error: cannot bind non-const lvalue reference of type ‘cv::Rect&’ {aka ‘cv::Rect_<int>&’} to an rvalue of type ‘cv::Rect_<int>’
ERR! install    44 |   ret = Tracker::unwrapThis(info)->getTracker()->update(image, rect);
ERR! install       |                                                                ^~~~
ERR! install In file included from /usr/include/opencv4/opencv2/core.hpp:58,
ERR! install                  from ../cc/macros.h:2,
ERR! install                  from ../cc/opencv_modules.h:1,
ERR! install                  from ../cc/tracking/Tracker.cc:1:
ERR! install /usr/include/opencv4/opencv2/core/types.hpp:1905:1: note:   after user-defined conversion: ‘cv::Rect_<_Tp>::operator cv::Rect_<_Tp2>() const [with _Tp2 = int; _Tp = double]’
ERR! install  1905 | Rect_<_Tp>::operator Rect_<_Tp2>() const
ERR! install       | ^~~~~~~~~~
ERR! install In file included from /usr/include/opencv4/opencv2/tracking.hpp:9,
ERR! install                  from ../cc/tracking/Tracker.h:2,
ERR! install                  from ../cc/tracking/Tracker.cc:5:
ERR! install /usr/include/opencv4/opencv2/video/tracking.hpp:737:48: note:   initializing argument 2 of ‘virtual bool cv::Tracker::update(cv::InputArray, cv::Rect&)’
ERR! install   737 |     bool update(InputArray image, CV_OUT Rect& boundingBox) = 0;
ERR! install       |                                          ~~~~~~^~~~~~~~~~~
ERR! install make: *** [opencv4nodejs.target.mk:259: Release/obj.target/opencv4nodejs/cc/tracking/tracking.o] Error 1
ERR! install make: *** Waiting for unfinished jobs....
ERR! install make: *** [opencv4nodejs.target.mk:259: Release/obj.target/opencv4nodejs/cc/tracking/Tracker.o] Error 1
ERR! install In file included from ../cc/tracking/MultiTracker.cc:5:
ERR! install ../cc/tracking/MultiTracker.h:17:70: error: ‘MultiTracker’ is not a member of ‘cv’; did you mean ‘MultiTracker’?
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |                                                                      ^~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.h:17:7: note: ‘MultiTracker’ declared here
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |       ^~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.h:17:70: error: template argument 1 is invalid
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |                                                                      ^~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.h:17:82: error: template argument 2 is invalid
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |                                                                                  ^~
ERR! install ../cc/tracking/MultiTracker.cc: In static member function ‘static Nan::NAN_METHOD_RETURN_TYPE MultiTracker::New(Nan::NAN_METHOD_ARGS_TYPE)’:
ERR! install ../cc/tracking/MultiTracker.cc:42:8: error: ‘class MultiTracker’ has no member named ‘setNativeObject’
ERR! install    42 |  self->setNativeObject(cv::makePtr<cv::MultiTracker>());
ERR! install       |        ^~~~~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.cc:42:40: error: ‘MultiTracker’ is not a member of ‘cv’; did you mean ‘MultiTracker’?
ERR! install    42 |  self->setNativeObject(cv::makePtr<cv::MultiTracker>());
ERR! install       |                                        ^~~~~~~~~~~~
ERR! install In file included from ../cc/tracking/MultiTracker.cc:5:
ERR! install ../cc/tracking/MultiTracker.h:17:7: note: ‘MultiTracker’ declared here
ERR! install    17 | class MultiTracker : public FF::ObjectWrap<MultiTracker, cv::Ptr<cv::MultiTracker>> {
ERR! install       |       ^~~~~~~~~~~~
ERR! install ../cc/tracking/MultiTracker.cc:42:54: error: no matching function for call to ‘makePtr<<expression error> >()’
ERR! install    42 |  self->setNativeObject(cv::makePtr<cv::MultiTracker>());
ERR! install       |                                                      ^
btsimonh commented 1 year ago

Hi @UrielCh,

I did install with build, and it just worked beautifully - thankyou :). (It ended up with a late v4 opencv...)

I'm building up some documentation on reading raw video, passing it through OpenCV, and on to Janus, consuming it in the browser using webrtc.

It's working really well with ~25% cpu used by node on RPi3b (just writing framecount onto the frame at 640x480@25), very low latency, and all from within Node-Red :).

I'm failing on drivers at higher resolutions at the moment, but it's a good start considering all the old/bad information I had to sift through to get here!!.

Suffice to say the v4l h264 encoder is hardware accelerated ... and Janus is not as scary as the lack of information would predict.

Thanks for continuing the opencv4nodejs - it's one of my favourite projects!

We could possibly do with the wiki enabled - @justadudewhohacks did some good work on the documentation, maybe we could copy that over?

very best,

Simon

btsimonh commented 1 year ago

FYI.. not anything final, but my docs repo for my rpi robot investigations are here: https://github.com/btsimonh/Adeept-rasptank-mods

The video.md covers my experiences with video & RPi3b.... br, Simon

UrielCh commented 1 year ago

Are you using a 64 or a 32 Kernel, if I remember the RPi3b is 64 capable.

btsimonh commented 1 year ago

pi@raspberrypi3b:~ $ uname --all Linux raspberrypi3b 5.15.84-v7+ #1613 SMP Thu Jan 5 11:59:48 GMT 2023 armv7l GNU/Linux

-> 32 bit?

pi@raspberrypi3b:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

Are there big advantages to 64 bit on a system with 1Gbyte ram?

(at some point as I get to the end of the 'gathering working technology' phase, I'd like to start a fresh SD card, and so advice on 32 vs 64 very relevant! - the current OS was a relatively fresh buster to start with, but with an odd networking arrangement with networkmanager, now reverted. A writeup of a complete fresh install would be a useful thing for others...).

I could also try pizerow -if only I had the right camera cable.

Do you have any experience of this on Jetson Nano? (won't fit in the robot; it's just I bought one some time ago and have not applied it to anything yet... I have a small commercial interest in a company which uses them for ANPR.... and would be nice to take control of the ANPR software solution via OpenCV in Node-Red.)

UrielCh commented 1 year ago

I just ask that to know if the project works build fin with a 32 bit kernel. you are already short in memory on a pi3B so, I do not recommand you the 64bit mode. but if you have ever try it, consider giving me some data as compilation time,

Why are you using pi3b ? is that dur to some shortage issue ?

I have no Jetson in stock, just a lots of raspberry pi 4,3,2, pico, nano, RP2040, ESP32, and a coral USB TPU.

I wish I can get an orange Pi5 or equivalant Rockchip RK3588S board.

btsimonh commented 1 year ago

I just had the pi3b lying around (it was my first pi, quite some years old). My pi4 (4gbyte) is 'occupied' running NR flows supporting the house.... but also the biggest issue I have to overcome is power - it's running from 2 x 18650 2.5Ah. With some 'extras' I've added, I'm not sure that the motor hat's 5v is really holding up.

to continue off-topic :).

I've been playing with resolutions and framerates in my config of raw video through OpenCV, encoding to h264 and pushing to browser as WebRTC. Camera is 5Mpixel.

The max res I can get whilst maintaining FPS is 1280x720@25 (using level=4 in encode). pi3b: ~70% (node) + ~10% (janus) cpu load as reported by top. The max fps I can get at 640x480 is 90 (~70% cpu).

If I ask for 1920, my fps drops to 5.... I'm not sure why.

I also tried scaling the output down. OpenCV's resize is slow compared to scaling in gstreamer. In the end, it uses more CPU to scale down before encode than to encode at the higher resolution, and does not enable more FPS at 1920x1080 input.

A few times I have had driver failure when asking for 640x480@30 or 29.97. If I close the capture/writer, and ask for a different fps first, then close again and ask for 30 again, it works. Odd.

Specifics of capture and writer strings are in the NR flow in the repo.

UrielCh commented 1 year ago

Have you some opensource ressources for ANPR in nodeJS / OpenCV. I would enjoy playing with that to identify cars in my dashcam video stream.

btsimonh commented 1 year ago

no, the company i'm a little involved with went with a commercial ANPR library/docker for jetson.

But I've been doing a lot with text detection/OCR from video for my main job, and it is REALLY difficult... Suffice to say things like East Text Detection are heavily overrated. ANPR would be child's play compared to what I'm trying to do!!! (recommend: pre-process image for contrast, then canny, contour. Look for the plate as a rectangular contour containing other contours (of the right size range). Correct the skew, detect the colours, mask, then OCR. If necessary, once you know the location of the ROI, start over excluding everything else. You should get >40fps on a decent PC for images ~1920x300. East -> 4fps for me :(. )