Skip to content

Exception in FacemarkLBF fit method #2140

@LaurentBerger

Description

@LaurentBerger

I think there is a bug in python binding using last opencv_contrib

General configuration for OpenCV 4.1.0-dev =====================================
Version control: 4.0.1-898-gf3de2b4be

Extra modules:
Location (extra): G:/Lib/opencv_contrib/modules
Version control (extra): 3.4.1-531-g250bcd9f

Platform:
Timestamp: 2019-05-24T11:22:17Z
Host: Windows 10.0.17763 AMD64
CMake: 3.13.2
CMake generator: Visual Studio 15 2017 Win64
CMake build tool: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe
MSVC: 1916

Detailed description

loading data from : F:/TestDNN/OpenFace/lbfmodel.yaml
[ INFO:0] global G:\Lib\opencv\modules\core\src\ocl.cpp (888) cv::ocl::haveOpenCL Initialize OpenCL runtime...
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(4.1.0-dev) Error: Assertion failed (channels() == CV_MAT_CN(dtype)) in cv::Mat::copyTo, file G:\Lib\opencv\modules\core\src\copy.cpp, line 254

Steps to reproduce
path_to_opencv_extra ='f:/lib/' 
frame = cv.imread(path_to_opencv_extra + 'opencv_extra/testdata/cv/face/david1.jpg')
if frame is None:
    print("image not found")
    exit()
facemark = cv.face.createFacemarkLBF()
facemark.loadModel("F:/TestDNN/OpenFace/lbfmodel.yaml")
cascade = cv.CascadeClassifier(path_to_opencv_extra + 'opencv_extra/testdata/cv/face/lbpcascade_frontalface_improved.xml')
if cascade.empty() :
    print("cascade not found")
    exit()
faces = cascade.detectMultiScale(frame, 1.05,  2, cv.CASCADE_SCALE_IMAGE, (30, 30))
ok, landmarks = facemark.fit(frame, faces)

How to solve it? https://github.com/LaurentBerger/opencv_contrib/blob/pyfacelandmark/modules/face/src/facemarkLBF.cpp#L373-L414

previous interface was better and this pr #2069 doesn't not solve previous bug

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions