Hi all,

OK. I made a patch to address this issue. Will upload the patch soon.


Yours,
Paul


Description: Porting to OpenCV4
 We need to port to OpenCV4 because Debian is now using OpenCV4
Author: Ying-Chun Liu (PaulLiu) <paul...@debian.org>
Bug-Debian: https://bugs.debian.org/922587
Last-Update: 2020-02-07

Index: node-opencv-6.0.0+git20180416.cfc96ba0/utils/find-opencv.js
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/utils/find-opencv.js
+++ node-opencv-6.0.0+git20180416.cfc96ba0/utils/find-opencv.js
@@ -16,6 +16,7 @@ var flag = flags[process.argv[2]] || '--
 // the same machine, the opencv.pc for 3.y can be installed as opencv3.pc and
 // then selected by |export PKG_CONFIG_OPENCV3=1| before building node-opencv.
 var opencv = process.env.PKG_CONFIG_OPENCV3 === "1" ? "opencv3" : ' "opencv >= 2.3.1"';
+opencv = process.env.PKG_CONFIG_OPENCV4 === "1" ? "opencv4" : opencv;
 
 function main(){
     //Try using pkg-config, but if it fails and it is on Windows, try the fallback
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/OpenCV.h
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/OpenCV.h
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/OpenCV.h
@@ -24,6 +24,8 @@
 
 #if ((CV_MAJOR_VERSION <= 2) && (CV_MINOR_VERSION <= 4) && (CV_MINOR_VERSION < 10))
 #include <opencv/highgui.h>
+#elif CV_MAJOR_VERSION >= 4
+#include <opencv2/imgcodecs/legacy/constants_c.h>
 #else
 #include <opencv2/imgcodecs/imgcodecs_c.h>
 #endif
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/Point.h
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/Point.h
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/Point.h
@@ -1,6 +1,7 @@
 // Template class for 2D points
 
 #include "OpenCV.h"
+#include <opencv2/core/types_c.h>
 
 class Point: public Nan::ObjectWrap {
 public:
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/Matrix.cc
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/Matrix.cc
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/Matrix.cc
@@ -3,6 +3,9 @@
 #include "OpenCV.h"
 #include <string.h>
 #include <nan.h>
+#include <opencv2/imgproc/types_c.h>
+#include <opencv2/imgproc/imgproc_c.h>
+
 
 Nan::Persistent<FunctionTemplate> Matrix::constructor;
 
@@ -1608,7 +1611,9 @@ NAN_METHOD(Matrix::Canny) {
   int lowThresh = info[0]->NumberValue();
   int highThresh = info[1]->NumberValue();
 
-  cv::Canny(self->mat, self->mat, lowThresh, highThresh);
+  cv::Mat newMat;
+  cv::Canny(self->mat, newMat, lowThresh, highThresh);
+  newMat.copyTo(self->mat);
 
   info.GetReturnValue().Set(Nan::Null());
 }
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/CascadeClassifierWrap.cc
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/CascadeClassifierWrap.cc
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/CascadeClassifierWrap.cc
@@ -2,6 +2,7 @@
 #include "OpenCV.h"
 #include "Matrix.h"
 #include <nan.h>
+#include <opencv2/imgproc/types_c.h>
 
 #ifdef HAVE_OPENCV_OBJDETECT
 
@@ -73,7 +74,7 @@ public:
         gray = this->im->mat;
       }
       this->cc->cc.detectMultiScale(gray, objects, this->scale, this->neighbors,
-          0 | CV_HAAR_SCALE_IMAGE, cv::Size(this->minw, this->minh));
+          0 | cv::CASCADE_SCALE_IMAGE, cv::Size(this->minw, this->minh));
       res = objects;
     } catch (cv::Exception& e) {
       SetErrorMessage(e.what());
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/VideoCaptureWrap.cc
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/VideoCaptureWrap.cc
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/VideoCaptureWrap.cc
@@ -3,6 +3,7 @@
 #include "OpenCV.h"
 
 #include  <iostream>
+#include <opencv2/videoio/legacy/constants_c.h>
 
 #ifdef HAVE_OPENCV_VIDEOIO
 
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/VideoWriterWrap.cc
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/VideoWriterWrap.cc
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/VideoWriterWrap.cc
@@ -1,6 +1,7 @@
 #include "VideoWriterWrap.h"
 #include "Matrix.h"
 #include "OpenCV.h"
+#include <opencv2/videoio/legacy/constants_c.h>
 
 #include  <iostream>
 
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/CamShift.cc
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/CamShift.cc
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/CamShift.cc
@@ -8,6 +8,8 @@
 #include <opencv2/video/tracking.hpp>
 #endif
 
+#include <opencv2/imgproc/types_c.h>
+
 #define CHANNEL_HUE 0
 #define CHANNEL_SATURATION 1
 #define CHANNEL_VALUE 2
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/FaceRecognizer.cc
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/FaceRecognizer.cc
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/FaceRecognizer.cc
@@ -4,9 +4,9 @@
 #include "FaceRecognizer.h"
 #include "Matrix.h"
 #include <nan.h>
+#include <opencv2/imgproc/types_c.h>
 
-#if CV_MAJOR_VERSION < 3
-#elif CV_MINOR_VERSION < 3
+#if CV_MAJOR_VERSION < 3 || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION < 3)
 namespace cv {
   using std::vector;
   using cv::face::createEigenFaceRecognizer;
@@ -92,7 +92,7 @@ NAN_METHOD(FaceRecognizerWrap::New) {
   }
 
   // By default initialize LBPH
-#if CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3
+#if CV_MAJOR_VERSION >= 4 || (CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3)
   cv::Ptr<cv::FaceRecognizer> f = cv::LBPHFaceRecognizer::create(1, 8, 8, 8, 80.0);
 #else 
   cv::Ptr<cv::FaceRecognizer> f = cv::createLBPHFaceRecognizer(1, 8, 8, 8, 80.0);
@@ -119,7 +119,7 @@ NAN_METHOD(FaceRecognizerWrap::CreateLBP
   DOUBLE_FROM_ARGS(threshold, 4)
 
   Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
-#if CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3
+#if CV_MAJOR_VERSION >= 4 || (CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3)
   cv::Ptr<cv::FaceRecognizer> f = cv::LBPHFaceRecognizer::create(radius, neighbors, grid_x, grid_y, threshold);
 #else 
   cv::Ptr<cv::FaceRecognizer> f = cv::createLBPHFaceRecognizer(radius, neighbors, grid_x, grid_y, threshold);
@@ -140,7 +140,7 @@ NAN_METHOD(FaceRecognizerWrap::CreateEig
   DOUBLE_FROM_ARGS(threshold, 1)
 
   Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
-#if CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3
+#if CV_MAJOR_VERSION >= 4 || (CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3)
   cv::Ptr<cv::FaceRecognizer> f = cv::EigenFaceRecognizer::create(components, threshold);
 #else
   cv::Ptr<cv::FaceRecognizer> f = cv::createEigenFaceRecognizer(components, threshold);
@@ -161,7 +161,7 @@ NAN_METHOD(FaceRecognizerWrap::CreateFis
   DOUBLE_FROM_ARGS(threshold, 1)
 
   Local<Object> n = Nan::NewInstance(Nan::GetFunction(Nan::New(FaceRecognizerWrap::constructor)).ToLocalChecked()).ToLocalChecked();
-#if CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3
+#if CV_MAJOR_VERSION >= 4 || (CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3)
   cv::Ptr<cv::FaceRecognizer> f = cv::FisherFaceRecognizer::create(components, threshold);
 #else
   cv::Ptr<cv::FaceRecognizer> f = cv::createFisherFaceRecognizer(components, threshold);
@@ -423,7 +423,7 @@ NAN_METHOD(FaceRecognizerWrap::SaveSync)
     JSTHROW("Save takes a filename")
   }
   std::string filename = std::string(*Nan::Utf8String(info[0]->ToString()));
-#if CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3
+#if CV_MAJOR_VERSION >= 4 || (CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3)
   self->rec->write(filename);
 #else
   self->rec->save(filename);
@@ -437,7 +437,7 @@ NAN_METHOD(FaceRecognizerWrap::LoadSync)
     JSTHROW("Load takes a filename")
   }
   std::string filename = std::string(*Nan::Utf8String(info[0]->ToString()));
-#if CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3  
+#if CV_MAJOR_VERSION >= 4 || (CV_MAJOR_VERSION >= 3  && CV_MINOR_VERSION >= 3)
   self->rec->read(filename);
 #else
   self->rec->load(filename);
Index: node-opencv-6.0.0+git20180416.cfc96ba0/src/Constants.cc
===================================================================
--- node-opencv-6.0.0+git20180416.cfc96ba0.orig/src/Constants.cc
+++ node-opencv-6.0.0+git20180416.cfc96ba0/src/Constants.cc
@@ -1,5 +1,6 @@
 #include "OpenCV.h"
 #include "Constants.h"
+#include <opencv2/imgproc/imgproc_c.h>
 
 #define CONST(C) \
   obj->Set(Nan::New<String>(#C).ToLocalChecked(), Nan::New<Integer>(C));
@@ -25,7 +26,9 @@ void Constants::Init(Local<Object> targe
   CONST(CV_32S);
   CONST(CV_32F);
   CONST(CV_64F);
+#if CV_MAJOR_VERSION <= 3
   CONST(CV_USRTYPE1);
+#endif
 
   CONST(CV_8UC1);
   CONST(CV_8UC2);

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
Pkg-javascript-devel mailing list
Pkg-javascript-devel@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/pkg-javascript-devel

Reply via email to