sm-commit AT lists.ibiblio.org
Subject: Source Mage code commit list
List archive
[SM-Commit] GIT changes to master grimoire by Eric Sandall (cf6a37452ad5b3fd1efd0496e341e8aec7a7a864)
- From: Eric Sandall <scm AT sourcemage.org>
- To: sm-commit AT lists.ibiblio.org
- Subject: [SM-Commit] GIT changes to master grimoire by Eric Sandall (cf6a37452ad5b3fd1efd0496e341e8aec7a7a864)
- Date: Fri, 4 Sep 2020 17:52:08 +0000
GIT changes to master grimoire by Eric Sandall <sandalle AT sourcemage.org>:
devel/python/HISTORY | 6
devel/python/INSTALL | 10
disk/grub2/BUILD | 6
disk/grub2/DETAILS | 1
disk/grub2/HISTORY | 6
graphics-libs/opencv/DETAILS | 8
graphics-libs/opencv/HISTORY | 9
graphics-libs/opencv/PRE_BUILD | 7
video-libs/frei0r-plugins/DETAILS | 4
video-libs/frei0r-plugins/HISTORY | 9
video-libs/frei0r-plugins/PRE_BUILD | 3
video-libs/frei0r-plugins/opencv-3.4.2.patch | 466
+++++++++++++++++++++++++++
12 files changed, 526 insertions(+), 9 deletions(-)
New commits:
commit cf6a37452ad5b3fd1efd0496e341e8aec7a7a864
Author: Eric Sandall <sandalle AT sourcemage.org>
Commit: Eric Sandall <sandalle AT sourcemage.org>
python: Use make install, otherwise install fails if we've somehow
removed/broken python
Without this, python -> python2 and python2 -> python ... so circular
links, not sure how.
Use TRACK_INSTALL for symlink targets
Don't try to copy a directory if it doesn't exist.
commit 11b09d0024bb685691cc227fae33ed83631da8f2
Author: Eric Sandall <sandalle AT sourcemage.org>
Commit: Eric Sandall <sandalle AT sourcemage.org>
grub2: Don't use gold linker (ld.gold), use old bfd.
PATCHLEVEL++ so you have a working GRUB.
Otherwise you might get this error:
grub-install: error: `/usr/lib/grub/i386-pc/kernel.img' is
miscompiled: its start address is 0x9074 instead of 0x9000: ld.gold bug?.
Kernel doesn't like ld.gold either:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=75959d44f9dc
May want to update the "linux" spell to do the same?
commit 6d1b357e16381e23f8718c0989361abcba781c1a
Author: Eric Sandall <sandalle AT sourcemage.org>
Commit: Eric Sandall <sandalle AT sourcemage.org>
frei0r-plugins: Updated to 1.7.0
Apply opencv-3.4.2.patch
* opencv-3.4.2.patch: Fixes building against opencv 3.4.2+
Modified from patches submitted to
https://github.com/dyne/frei0r/issues/26
And also include
https://github.com/dyne/frei0r/commit/ce89da4892e5b7e28787b7d2231b670f2da02054
to fix more changes from OpenCV. OpenCV seems to like changing how things
work in minor revisions...
commit 7d9c65d49644114083dc4e0a2cf5cd0c1d42b3f3
Author: Eric Sandall <sandalle AT sourcemage.org>
Commit: Eric Sandall <sandalle AT sourcemage.org>
opencv: Updated to 3.4.11
Now compiles with GCC 10.
Add IPPICV as SOURCE2 so we can download it before compile time
Only grabbed Linux 64-bit version, there's also a 32-bit one.
Verified with MD5 hash from
https://fossies.org/linux/opencv/3rdparty/ippicv/ippicv.cmake
Copy SOURCE2 to .cache/ippicv/ so cmake doesn't download it
See https://fossies.org/linux/opencv/3rdparty/ippicv/ippicv.cmake
diff --git a/devel/python/HISTORY b/devel/python/HISTORY
index 6f6e4cd..1dbd333 100644
--- a/devel/python/HISTORY
+++ b/devel/python/HISTORY
@@ -1,3 +1,9 @@
+2020-09-03 Eric Sandall <sandalle AT sourcemage.org>
+ * INSTALL: Use make install, otherwise install fails if we've somehow
removed/broken python
+ Without this, python -> python2 and python2 -> python ... so
circular links, not sure how.
+ Use TRACK_INSTALL for symlink targets
+ Don't try to copy a directory if it doesn't exist.
+
2020-04-20 Vlad Glagolev <stealth AT sourcemage.org>
* DETAILS: updated spell to 2.7.18; SECURITY_PATCH++ (CVE-2019-18348)
* INSTALL: correct path check and fix linking
diff --git a/devel/python/INSTALL b/devel/python/INSTALL
index d323281..9d66b97 100755
--- a/devel/python/INSTALL
+++ b/devel/python/INSTALL
@@ -1,4 +1,4 @@
-cp -dRv "$SOURCE_DIRECTORY/anywhere/$INSTALL_ROOT/usr" "$INSTALL_ROOT/" &&
+make install DESTDIR="$INSTALL_ROOT" &&
if [[ -f "$SOURCE_DIRECTORY/spell-tmp/pydcop.py" ]]; then
cp "$SOURCE_DIRECTORY/spell-tmp/pydcop.py" "$PYPATH"
@@ -14,14 +14,14 @@ local PYVER=`echo ${VERSION}|cut -d . -f 1,2` &&
# symlinks, as they are not created with altinstall.
# See https://mail.python.org/pipermail/python-dev/2011-March/108971.html
# and the surrounding thread for fun.
-ln -sf python$PYVER "$INSTALL_ROOT/usr/bin/python"
-ln -sf python$PYVER "$INSTALL_ROOT/usr/bin/python2" &&
-ln -sf python$PYVER-config "$INSTALL_ROOT/usr/bin/python2-config" &&
+ln -sf "${TRACK_ROOT}/usr/bin/python$PYVER" "$INSTALL_ROOT/usr/bin/python"
|| true # always fails?
+ln -sf "${TRACK_ROOT}/usr/bin/python$PYVER" "$INSTALL_ROOT/usr/bin/python2"
&&
+ln -sf "${TRACK_ROOT}/usr/bin/python$PYVER-config"
"$INSTALL_ROOT/usr/bin/python2-config" &&
if [ -d "${INSTALL_ROOT}/usr/lib/python${PYVER}/plat-linux2" ];then
cp -r "${INSTALL_ROOT}/usr/lib/python${PYVER}/plat-linux2" \
"${INSTALL_ROOT}/usr/lib/python${PYVER}/plat-linux3"
-else
+elif [ -d "${INSTALL_ROOT}/usr/lib/python${PYVER}/plat-linux3" ] ; then
cp -r "${INSTALL_ROOT}/usr/lib/python${PYVER}/plat-linux3" \
"${INSTALL_ROOT}/usr/lib/python${PYVER}/plat-linux2"
fi
diff --git a/disk/grub2/BUILD b/disk/grub2/BUILD
index 2e88569..cdcba2c 100755
--- a/disk/grub2/BUILD
+++ b/disk/grub2/BUILD
@@ -4,5 +4,11 @@ CFLAGS=${CFLAGS//-m64/} &&
CFLAGS=$(echo ${CFLAGS} | sed -r "s;-O([0-9]|fast);-Os;g") &&
LDFLAGS=${LDFLAGS//-s /} &&
LDFLAGS=${LDFLAGS%-s} &&
+# Don't use gold linker (ld.gold), use old bfd
+# Otherwise you might get this error:
+# grub-install: error: `/usr/lib/grub/i386-pc/kernel.img' is miscompiled:
its start address is 0x9074 instead of 0x9000: ld.gold bug?.
+LDFLAGS=${LDFLAGS//-Wl,-fuse-ld=gold/} &&
+LDFLAGS+=" -Wl,-fuse-ld=bfd" &&
+
disable_pic force &&
default_build
diff --git a/disk/grub2/DETAILS b/disk/grub2/DETAILS
index af32b1f..1d37b7e 100755
--- a/disk/grub2/DETAILS
+++ b/disk/grub2/DETAILS
@@ -1,5 +1,6 @@
SPELL=grub2
STAGED_INSTALL="off"
+ PATCHLEVEL=1
case "$GRUB2_RELEASE" in
beta)
VERSION=2.02-beta3
diff --git a/disk/grub2/HISTORY b/disk/grub2/HISTORY
index 2a0a8c5..3183598 100644
--- a/disk/grub2/HISTORY
+++ b/disk/grub2/HISTORY
@@ -1,3 +1,9 @@
+2020-09-02 Eric Sandall <sandalle AT sourcemage.org>
+ * DETAILS: PATCHLEVEL++ so you have a working GRUB.
+ * BUILD: Don't use gold linker (ld.gold), use old bfd. Otherwise you
might get this error:
+ grub-install: error: `/usr/lib/grub/i386-pc/kernel.img' is
miscompiled: its start address is 0x9074 instead of 0x9000: ld.gold bug?.
+ Kernel doesn't like ld.gold either:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=75959d44f9dc
+
2020-08-21 Eric Sandall <sandalle AT sourcemage.org>
* DETAILS: Disable castfs (STAGED_INSTALL), breaks install
diff --git a/graphics-libs/opencv/DETAILS b/graphics-libs/opencv/DETAILS
index eade82c..95557e1 100755
--- a/graphics-libs/opencv/DETAILS
+++ b/graphics-libs/opencv/DETAILS
@@ -1,9 +1,13 @@
SPELL=opencv
- VERSION=3.4.0
-
SOURCE_HASH=sha512:aa7e475f356ffdaeb2ae9f7e9380c92cae58fabde9cd3b23c388f9190b8fde31ee70d16648042d0c43c03b2ff1f15e4be950be7851133ea0aa82cf6e42ba4710
+ VERSION=3.4.11
+ IPPICV_COMMIT="a56b6ac6f030c312b2dce17430eef13aed9af274"
SOURCE=$SPELL-$VERSION.tar.gz
+ SOURCE2=ippicv_2020_lnx_intel64_20191018_general.tgz
+
SOURCE_HASH=sha512:1d80709d974dcf191e1a53574e00fbc8cd6dea6a6e9e7d3cfd971cbb38fa89dc6b1bc50d2238cf75dec6de4901761a47e6f2953d3940eab4d4fd52b978e1d035
+
SOURCE2_HASH=sha512:de6d80695cd6deef359376476edc4ff85fdddcf94972b936e0017f8a48aaa5d18f55c4253ae37deb83bff2f71410f68408063c88b5f3bf4df3c416aa93ceca87
SOURCE_DIRECTORY=$BUILD_DIRECTORY/$SPELL-${VERSION}
SOURCE_URL[0]=https://github.com/Itseez/opencv/archive/$VERSION.tar.gz
+
SOURCE2_URL[0]=https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/${SOURCE2}
TMPFS=off
WEB_SITE=http://opencv.org
LICENSE[0]=BSD
diff --git a/graphics-libs/opencv/HISTORY b/graphics-libs/opencv/HISTORY
index ac98b7d..e55da34 100644
--- a/graphics-libs/opencv/HISTORY
+++ b/graphics-libs/opencv/HISTORY
@@ -1,3 +1,12 @@
+2020-09-01 Erix Sandall <sandalle AT sourcemage.org>
+ * DETAILS: Updated to 3.4.11
+ Now compiles with GCC 10.
+ Add IPPICV as SOURCE2 so we can download it before compile time
+ Only grabbed Linux 64-bit version, there's also a 32-bit one.
+ Verified with MD5 hash from
https://fossies.org/linux/opencv/3rdparty/ippicv/ippicv.cmake
+ * PRE_BUILD: Copy SOURCE2 to .cache/ippicv/ so cmake doesn't download
it
+ See https://fossies.org/linux/opencv/3rdparty/ippicv/ippicv.cmake
+
2018-11-19 Treeve Jelbert <treeve AT sourcemage.org>
* CONFLICTS: add opencv4
diff --git a/graphics-libs/opencv/PRE_BUILD b/graphics-libs/opencv/PRE_BUILD
new file mode 100755
index 0000000..71487ef
--- /dev/null
+++ b/graphics-libs/opencv/PRE_BUILD
@@ -0,0 +1,7 @@
+mk_source_dir ${SOURCE_DIRECTORY} &&
+cd ${BUILD_DIRECTORY} &&
+verify_file '' &&
+verify_file '2' &&
+unpack_file &&
+mkdir -p "${SOURCE_DIRECTORY}/.cache/ippicv" &&
+cp "${SOURCE_CACHE}/${SOURCE2}"
"${SOURCE_DIRECTORY}/.cache/ippicv/7421de0095c7a39162ae13a6098782f9-${SOURCE2}"
diff --git a/video-libs/frei0r-plugins/DETAILS
b/video-libs/frei0r-plugins/DETAILS
index f573670..b86b2eb 100755
--- a/video-libs/frei0r-plugins/DETAILS
+++ b/video-libs/frei0r-plugins/DETAILS
@@ -1,9 +1,9 @@
SPELL=frei0r-plugins
- VERSION=1.5.0
+ VERSION=1.7.0
SOURCE=$SPELL-$VERSION.tar.gz
SOURCE_DIRECTORY=$BUILD_DIRECTORY/$SPELL-$VERSION
SOURCE_URL[0]=https://files.dyne.org/frei0r/${SOURCE}
-
SOURCE_HASH=sha512:9be0384421ff5ac9000dcda9acefb5cb2b6dc05ea72d9771fae990cb5fad4424dcef8dd15c1e5031a89169f914af8c7a30e47934ad007a3bc0150f3c005bc6bf
+
SOURCE_HASH=sha512:8c80e8e0ce8c302e633ea1f6ff4e2a141fd7a8bcb7fce25dc7f1f6521be11258a3efa1074c224c7323e6a17bc405413385be193a5c787e2f276252b50477ebce
LICENSE[0]=GPL
WEB_SITE=http://frei0r.dyne.org/
ENTERED=20101210
diff --git a/video-libs/frei0r-plugins/HISTORY
b/video-libs/frei0r-plugins/HISTORY
index e936c61..f819fca 100644
--- a/video-libs/frei0r-plugins/HISTORY
+++ b/video-libs/frei0r-plugins/HISTORY
@@ -1,3 +1,11 @@
+2020-09-02 Eric Sandall <sandalle AT sourcemage.org>
+ * DETAILS: Updated to 1.7.0
+ * PRE_BUILD: Apply opencv-3.4.2.patch
+ * opencv-3.4.2.patch: Fixes building against opencv 3.4.2+
+ Modified from patches submitted to
https://github.com/dyne/frei0r/issues/26
+ And also include
https://github.com/dyne/frei0r/commit/ce89da4892e5b7e28787b7d2231b670f2da02054
+ to fix more changes from OpenCV. OpenCV seems to like changing how
things work in minor revisions...
+
2016-09-11 Florian Franzmann <siflfran AT hawo.stw.uni-erlangen.de>
* DETAILS, BUILD, DEPENDS: version 1.5.0, use cmake as build system
@@ -9,3 +17,4 @@
2010-12-10 Robin Cook <rcook AT wyrms.net>
* new spell: DETAILS DEPENDS
+
diff --git a/video-libs/frei0r-plugins/PRE_BUILD
b/video-libs/frei0r-plugins/PRE_BUILD
new file mode 100755
index 0000000..48024ef
--- /dev/null
+++ b/video-libs/frei0r-plugins/PRE_BUILD
@@ -0,0 +1,3 @@
+default_pre_build &&
+cd "${SOURCE_DIRECTORY}" &&
+patch -p1 < "${SCRIPT_DIRECTORY}/opencv-3.4.2.patch"
diff --git a/video-libs/frei0r-plugins/opencv-3.4.2.patch
b/video-libs/frei0r-plugins/opencv-3.4.2.patch
new file mode 100644
index 0000000..8e3e7f2
--- /dev/null
+++ b/video-libs/frei0r-plugins/opencv-3.4.2.patch
@@ -0,0 +1,466 @@
+# Modified from patches submitted to https://github.com/dyne/frei0r/issues/26
+diff -Naur frei0r-plugins-1.7.0.orig/src/filter/facebl0r/facebl0r.cpp
frei0r-plugins-1.7.0/src/filter/facebl0r/facebl0r.cpp
+--- frei0r-plugins-1.7.0.orig/src/filter/facebl0r/facebl0r.cpp 2020-09-02
10:18:33.365818984 -0700
++++ frei0r-plugins-1.7.0/src/filter/facebl0r/facebl0r.cpp 2020-09-02
10:18:57.807629283 -0700
+@@ -15,10 +15,18 @@
+ */
+
+
++#include <opencv2/core/version.hpp>
++#define CV_VERSION_NUM (CV_VERSION_MAJOR * 10000 \
++ + CV_VERSION_MINOR * 100 \
++ + CV_VERSION_REVISION)
++
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <opencv2/opencv.hpp>
++#if CV_VERSION_NUM > 30401
++#include <opencv2/imgproc.hpp>
++#endif
+ #include "frei0r.hpp"
+ #include "frei0r_math.h"
+
+# More updates from
https://github.com/dyne/frei0r/commit/ce89da4892e5b7e28787b7d2231b670f2da02054
to compile against more changes in OpenCV
+From ce89da4892e5b7e28787b7d2231b670f2da02054 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens AT rwth-aachen.de>
+Date: Wed, 1 Jan 2020 22:59:24 +0100
+Subject: [PATCH] Port facebl0r to OpenCV C++ API
+
+TrackedObj has been converted to a class, and the update_hue_image and
+camshift_track_face methods are now members of it, instead of passing
+the object as a parameter.
+
+Also, the various cv::Mat instances are kept, instead of destroying and
+recreating these on various occasions.
+
+The plugin now only accepts BGRA8888 as image format, as this is the
+expected layout throughout the code (default openCV channel order).
+
+The plugin has been tested using the following gstreamer pipeline:
+gst-launch-1.0 v4l2src ! image/jpeg,width=640,rate=1/15 \
+ ! jpegdec ! videoconvert \
+ ! frei0r-filter-facebl0r ellipse=1 \
+
classifier=/usr/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml
\
+ ! videoconvert ! autovideosink
+---
+ src/filter/facebl0r/facebl0r.cpp | 292 +++++++++++--------------------
+ 1 file changed, 102 insertions(+), 190 deletions(-)
+
+diff --git a/src/filter/facebl0r/facebl0r.cpp
b/src/filter/facebl0r/facebl0r.cpp
+index 17446cc..96222d8 100644
+--- a/src/filter/facebl0r/facebl0r.cpp
++++ b/src/filter/facebl0r/facebl0r.cpp
+@@ -22,49 +22,49 @@
+ #include "frei0r.hpp"
+ #include "frei0r_math.h"
+
+-typedef struct {
+- IplImage* hsv; //input image converted to HSV
+- IplImage* hue; //hue channel of HSV image
+- IplImage* mask; //image for masking pixels
+- IplImage* prob; //face probability estimates for each pixel
++class TrackedObj {
++public:
++ void update_hist();
++ void update_hue_image (const cv::Mat& image);
++ cv::RotatedRect camshift_track_face();
++
++ cv::Mat hsv; //input image converted to HSV
++ cv::Mat hue; //hue channel of HSV image
++ cv::Mat mask; //image for masking pixels
++ cv::Mat prob; //face probability estimates for each pixel
+
+- CvHistogram* hist; //histogram of hue in original face image
++ cv::Mat hist; //histogram of hue in original face image
++ static const int hist_bins; //number of histogram bins
++ static const float hist_range[2]; //histogram range
++
++ cv::Rect prev_rect; //location of face in previous frame
++ cv::RotatedRect curr_box; //current face location estimate
++};
+
+- CvRect prev_rect; //location of face in previous frame
+- CvBox2D curr_box; //current face location estimate
+-} TrackedObj;
++const float TrackedObj::hist_range[2] = { 0, 180 };
++const int TrackedObj::hist_bins = 30;
+
+ class FaceBl0r: public frei0r::filter {
+
+ public:
+ FaceBl0r(int wdt, int hgt);
+- ~FaceBl0r();
++ ~FaceBl0r() = default;
+
+ void update(double time,
+ uint32_t* out,
+ const uint32_t* in);
+
+ private:
+-
+-// camshift
+- TrackedObj* create_tracked_object (IplImage* image, CvRect* face_rect);
+- void destroy_tracked_object (TrackedObj* tracked_obj);
+- CvBox2D camshift_track_face (IplImage* image, TrackedObj* imgs);
+- void update_hue_image (const IplImage* image, TrackedObj* imgs);
+-
++
+ //trackface
+- CvRect* detect_face (IplImage*, CvHaarClassifierCascade*,
CvMemStorage*);
+-
++ std::vector<cv::Rect> detect_face();
++
++ TrackedObj tracked_obj;
+
+- TrackedObj* tracked_obj;
+- CvBox2D face_box; //area to draw
+- CvRect* face_rect;
+-
+ //used by capture_video_frame, so we don't have to keep creating.
+- IplImage* image;
++ cv::Mat image;
+
+- CvHaarClassifierCascade* cascade;
+- CvMemStorage* storage;
++ cv::CascadeClassifier cascade;
+
+ // plugin parameters
+ std::string classifier;
+@@ -77,7 +77,6 @@ class FaceBl0r: public frei0r::filter {
+ double largest;
+
+ std::string old_classifier;
+-
+
+ unsigned int face_found;
+ unsigned int face_notfound;
+@@ -87,18 +86,12 @@ class FaceBl0r: public frei0r::filter {
+ frei0r::construct<FaceBl0r> plugin("FaceBl0r",
+ "automatic face blur",
+ "ZioKernel, Biilly, Jilt, Jaromil,
ddennedy",
+- 1,1, F0R_COLOR_MODEL_PACKED32);
++ 1,1, F0R_COLOR_MODEL_BGRA8888);
+
+ FaceBl0r::FaceBl0r(int wdt, int hgt) {
+
+- face_rect = 0;
+- image = 0;
+- tracked_obj = 0;
+ face_found = 0;
+-
+- cascade = 0;
+- storage = 0;
+-
++
+ classifier =
"/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml";
+ register_param(classifier,
+ "Classifier",
+@@ -120,52 +113,35 @@ FaceBl0r::FaceBl0r(int wdt, int hgt) {
+ register_param(largest, "Largest", "Maximum object size in pixels,
divided by 10000");
+ }
+
+-FaceBl0r::~FaceBl0r() {
+- if(tracked_obj)
+- destroy_tracked_object(tracked_obj);
+-
+- if(cascade) cvReleaseHaarClassifierCascade(&cascade);
+- if(storage) cvReleaseMemStorage(&storage);
+-
+-}
+-
+ void FaceBl0r::update(double time,
+ uint32_t* out,
+- const uint32_t* in) {
+-
+- if (!cascade) {
+- cvSetNumThreads(cvRound(threads * 100));
+- if (classifier.length() > 0) {
+- if (classifier == old_classifier) {
+- // same as before, avoid repeating error messages
+- memcpy(out, in, size * 4); // of course assuming we are RGBA only
+- return;
+- } else old_classifier = classifier;
+-
+- cascade = (CvHaarClassifierCascade*) cvLoad(classifier.c_str(), 0, 0,
0 );
+- if (!cascade) {
+- fprintf(stderr, "ERROR in filter facebl0r, classifier cascade not
found:\n");
+- fprintf(stderr, " %s\n", classifier.c_str());
+- memcpy(out, in, size * 4);
+- return;
+- }
+- storage = cvCreateMemStorage(0);
+- }
+- else {
+- memcpy(out, in, size * 4);
+- return;
+- }
+- }
++ const uint32_t* in)
++{
++ if (cascade.empty()) {
++ cv::setNumThreads(cvRound(threads * 100));
++ if (classifier.length() == 0 || classifier == old_classifier) {
++ // same as before, avoid repeating error messages
++ memcpy(out, in, size * 4); // of course assuming we are RGBA
only
++ return;
++ }
++ old_classifier = classifier;
++ }
++
++ if (!cascade.load(classifier.c_str())) {
++ fprintf(stderr, "ERROR in filter facebl0r, classifier cascade not
found:\n");
++ fprintf(stderr, " %s\n", classifier.c_str());
++ memcpy(out, in, size * 4);
++ return;
++ }
+
+ // sanitize parameters
+ recheck = CLAMP(recheck, 0.001, 1.0);
+ search_scale = CLAMP(search_scale, 0.11, 1.0);
+ neighbors = CLAMP(neighbors, 0.01, 1.0);
+
+- if( !image )
+- image = cvCreateImage( cvSize(width,height), IPL_DEPTH_8U, 4 );
+-
+- memcpy(image->imageData, in, size * 4);
++ // copy input image to OpenCV
++ image = cv::Mat(height, width, CV_8UC4, (void*)in);
++ tracked_obj.update_hue_image(image);
+
+ /*
+ no face*
+@@ -176,27 +152,24 @@ void FaceBl0r::update(double time,
+ no face*
+ */
+ if(face_notfound>0) {
+-
++ std::vector<cv::Rect> faces;
+ if(face_notfound % cvRound(recheck * 1000) == 0)
+- face_rect = detect_face(image, cascade, storage);
++ faces = detect_face();
+
+ // if no face detected
+- if (!face_rect) {
++ if (faces.empty()) {
+ face_notfound++;
+ } else {
+- //track detected face with camshift
+- if(tracked_obj)
+- destroy_tracked_object(tracked_obj);
+- tracked_obj = create_tracked_object(image, face_rect);
++ tracked_obj.prev_rect = faces[0];
++ tracked_obj.update_hist();
+ face_notfound = 0;
+ face_found++;
+ }
+-
+ }
+
+- if(face_found>0) {
++ if (face_found > 0) {
+ //track the face in the new frame
+- face_box = camshift_track_face(image, tracked_obj);
++ cv::RotatedRect face_box = tracked_obj.camshift_track_face();
+
+ int min = cvRound(smallest * 1000);
+ min = min? min : 10;
+@@ -210,17 +183,13 @@ void FaceBl0r::update(double time,
+ face_notfound++;
+ }
+ else {
+-////////////////////////////////////////////////////////////////////////
+- cvSetImageROI (image, tracked_obj->prev_rect);
+-// cvSmooth (image, image, CV_BLUR, 22, 22, 0, 0);
+- cvSmooth (image, image, CV_BLUR, 23, 23, 0, 0);
+-// cvSmooth (image, image, CV_GAUSSIAN, 11, 11, 0, 0);
+- cvResetImageROI (image);
+-////////////////////////////////////////////////////////////////////////
+-
++ cv::Rect blur_region = tracked_obj.prev_rect & cv::Rect({0, 0},
image.size());
++ cv::Mat blur(image, blur_region);
++ cv::blur(blur, blur, {23, 23}, cv::Point(-1, -1));
++
+ //outline face ellipse
+ if (ellipse)
+- cvEllipseBox(image, face_box, CV_RGB(255,0,0), 2, CV_AA, 0);
++ cv::ellipse(image, face_box, CV_RGB(255,0,0), 2, cv::LINE_AA);
+
+ face_found++;
+ if(face_found % cvRound(recheck * 1000) == 0)
+@@ -228,133 +197,76 @@ void FaceBl0r::update(double time,
+ }
+ }
+
+- memcpy(out, image->imageData, size * 4);
+- cvReleaseImage(&image);
++ memcpy(out, image.data, size * 4);
+ }
+
+ /* Given an image and a classider, detect and return region. */
+-CvRect* FaceBl0r::detect_face (IplImage* image,
+- CvHaarClassifierCascade* cascade,
+- CvMemStorage* storage) {
+-
+- CvRect* rect = 0;
+-
+- if (cascade && storage) {
++std::vector<cv::Rect> FaceBl0r::detect_face()
++{
++ if (cascade.empty()) {
++ return std::vector<cv::Rect>();
++ }
++
+ //use an equalized gray image for better recognition
+- IplImage* gray = cvCreateImage(cvSize(image->width, image->height), 8,
1);
+- cvCvtColor(image, gray, CV_BGR2GRAY);
+- cvEqualizeHist(gray, gray);
+- cvClearMemStorage(storage);
++ cv::Mat gray;
++ cv::cvtColor(image, gray, CV_BGR2GRAY);
++ cv::equalizeHist(gray, gray);
+
+ //get a sequence of faces in image
+ int min = cvRound(smallest * 1000);
+- CvSeq *faces = cvHaarDetectObjects(gray, cascade, storage,
++ std::vector<cv::Rect> faces;
++ cascade.detectMultiScale(gray, faces,
+ search_scale * 10.0,
+ cvRound(neighbors * 100),
+ CV_HAAR_FIND_BIGGEST_OBJECT|//since we track only the first, get
the biggest
+ CV_HAAR_DO_CANNY_PRUNING, //skip regions unlikely to contain a
face
+- cvSize(min, min));
+-
+- //if one or more faces are detected, return the first one
+- if(faces && faces->total)
+- rect = (CvRect*) cvGetSeqElem(faces, 0);
++ cv::Size(min, min));
+
+- cvReleaseImage(&gray);
+- }
+-
+- return rect;
++ return faces;
+ }
+
+-/* Create a camshift tracked object from a region in image. */
+-TrackedObj* FaceBl0r::create_tracked_object (IplImage* image, CvRect*
region) {
+- TrackedObj* obj;
+-
+- //allocate memory for tracked object struct
+- if((obj = (TrackedObj *) malloc(sizeof *obj)) != NULL) {
+- //create-image: size(w,h), bit depth, channels
+- obj->hsv = cvCreateImage(cvGetSize(image), 8, 3);
+- obj->mask = cvCreateImage(cvGetSize(image), 8, 1);
+- obj->hue = cvCreateImage(cvGetSize(image), 8, 1);
+- obj->prob = cvCreateImage(cvGetSize(image), 8, 1);
+-
+- int hist_bins = 30; //number of histogram bins
+- float hist_range[] = {0,180}; //histogram range
+- float* range = hist_range;
+- obj->hist = cvCreateHist(1, //number of hist dimensions
+- &hist_bins, //array of dimension sizes
+- CV_HIST_ARRAY, //representation format
+- &range, //array of ranges for bins
+- 1); //uniformity flag
+- }
+-
+- //create a new hue image
+- update_hue_image(image, obj);
+-
+- float max_val = 0.f;
+-
++void TrackedObj::update_hist()
++{
+ //create a histogram representation for the face
+- cvSetImageROI(obj->hue, *region);
+- cvSetImageROI(obj->mask, *region);
+- cvCalcHist(&obj->hue, obj->hist, 0, obj->mask);
+- cvGetMinMaxHistValue(obj->hist, 0, &max_val, 0, 0 );
+- cvConvertScale(obj->hist->bins, obj->hist->bins,
+- max_val ? 255.0/max_val : 0, 0);
+- cvResetImageROI(obj->hue);
+- cvResetImageROI(obj->mask);
+-
+- //store the previous face location
+- obj->prev_rect = *region;
+-
+- return obj;
+-}
+-
+-/* Release resources from tracked object. */
+-void FaceBl0r::destroy_tracked_object (TrackedObj* obj) {
+- cvReleaseImage(&obj->hsv);
+- cvReleaseImage(&obj->hue);
+- cvReleaseImage(&obj->mask);
+- cvReleaseImage(&obj->prob);
+- cvReleaseHist(&obj->hist);
++ cv::Mat hue_roi(hue, prev_rect);
++ cv::Mat mask_roi(mask, prev_rect);
+
+- free(obj);
++ const float* range = hist_range;
++ cv::calcHist(&hue_roi, 1, nullptr, mask_roi, hist, 1, &hist_bins, &range);
++ normalize(hist, hist, 0, 255, cv::NORM_MINMAX);
+ }
+
+ /* Given an image and tracked object, return box position. */
+-CvBox2D FaceBl0r::camshift_track_face (IplImage* image, TrackedObj* obj) {
+- CvConnectedComp components;
+-
+- //create a new hue image
+- update_hue_image(image, obj);
+-
++cv::RotatedRect TrackedObj::camshift_track_face()
++{
+ //create a probability image based on the face histogram
+- cvCalcBackProject(&obj->hue, obj->prob, obj->hist);
+- cvAnd(obj->prob, obj->mask, obj->prob, 0);
++ const float* range = hist_range;
++ cv::calcBackProject(&hue, 1, nullptr, hist, prob, &range);
++ prob &= mask;
+
+ //use CamShift to find the center of the new face probability
+- cvCamShift(obj->prob, obj->prev_rect,
+- cvTermCriteria(CV_TERMCRIT_EPS | CV_TERMCRIT_ITER, 10, 1),
+- &components, &obj->curr_box);
++ cv::RotatedRect curr_box = CamShift(prob, prev_rect,
++ cv::TermCriteria(cv::TermCriteria::EPS | cv::TermCriteria::MAX_ITER,
10, 1 ));
+
+- //update face location and angle
+- obj->prev_rect = components.rect;
+- obj->curr_box.angle = -obj->curr_box.angle;
++ //update face location
++ prev_rect = curr_box.boundingRect();
+
+- return obj->curr_box;
++ return curr_box;
+ }
+
+-void FaceBl0r::update_hue_image (const IplImage* image, TrackedObj* obj) {
++void TrackedObj::update_hue_image (const cv::Mat& image) {
+ //limits for calculating hue
+ int vmin = 65, vmax = 256, smin = 55;
+-
++
+ //convert to HSV color model
+- cvCvtColor(image, obj->hsv, CV_BGR2HSV);
+-
++ cv::cvtColor(image, hsv, CV_BGR2HSV);
++
+ //mask out-of-range values
+- cvInRangeS(obj->hsv, //source
+- cvScalar(0, smin, MIN(vmin, vmax), 0), //lower bound
+- cvScalar(180, 256, MAX(vmin, vmax) ,0), //upper bound
+- obj->mask); //destination
+-
++ cv::inRange(hsv, //source
++ cv::Scalar(0, smin, MIN(vmin, vmax)), //lower bound
++ cv::Scalar(180, 256, MAX(vmin, vmax)), //upper bound
++ mask); //destination
++
+ //extract the hue channel, split: src, dest channels
+- cvSplit(obj->hsv, obj->hue, 0, 0, 0 );
++ cv::extractChannel(hsv, hue, 0);
+ }
+
- [SM-Commit] GIT changes to master grimoire by Eric Sandall (cf6a37452ad5b3fd1efd0496e341e8aec7a7a864), Eric Sandall, 09/04/2020
Archive powered by MHonArc 2.6.24.