Skip to content

Commit

Permalink
fix face module inheritance (#263)
Browse files Browse the repository at this point in the history
* fix inheritance issues for `cv::face::*FaceRecognizer`

* fix header guards

* remove extra debug code

Signed-off-by: Cocoa <[email protected]>

---------

Signed-off-by: Cocoa <[email protected]>
  • Loading branch information
cocoa-xu authored Aug 4, 2024
1 parent 29d90ac commit 1a12402
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion c_src/modules/evision_cuda_ipc.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef EVISION_CUDA_IPC_H
#define EVISION_CUDA_H
#define EVISION_CUDA_IPC_H

#pragma once

Expand Down
5 changes: 3 additions & 2 deletions py_src/class_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def gen_erl_func_list(self, codegen):
base_class == "GraphicalCodeDetector"
or current_class.cname.startswith("cv::ml")
or "Calibrate" in current_class.cname
or "Calibrate" in current_class.cname
or "FaceRecognizer" in current_class.cname
or (current_class.base is not None and "Feature2D" in current_class.base)
or (current_class.base is not None and "Matcher" in current_class.base)
or (current_class.base is not None and "Algorithm" in current_class.base)
Expand Down Expand Up @@ -248,7 +248,8 @@ def gen_code(self, codegen):
and (
base_class == "GraphicalCodeDetector"
or current_class.cname.startswith("cv::ml")
or "Calibrate" in current_class.cname
or "Calibrate" in current_class.cname
or "FaceRecognizer" in current_class.cname
or (current_class.base is not None and "Feature2D" in current_class.base)
or (current_class.base is not None and "Matcher" in current_class.base)
or (current_class.base is not None and "Algorithm" in current_class.base)
Expand Down
2 changes: 2 additions & 0 deletions py_src/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,8 @@ def is_struct(argtype: str, also_get: Optional[str] = None, classname: Optional[
'Facemark': 'Evision.Face.Facemark',
'Face.Facemark': 'Evision.Face.Facemark',
'Face.FaceRecognizer': 'Evision.Face.FaceRecognizer',
'Face.EigenFaceRecognizer': 'Evision.Face.EigenFaceRecognizer',
'Face.FisherFaceRecognizer': 'Evision.Face.FisherFaceRecognizer',
'Face.MACE': 'Evision.Face.MACE',
'FaceDetectorYN': 'Evision.FaceDetectorYN',
'FaceRecognizerSF': 'Evision.FaceRecognizerSF',
Expand Down
33 changes: 33 additions & 0 deletions test/evision_face_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
defmodule Evision.Face.FaceRecognizerTest do
use ExUnit.Case

setup do
%Evision.Mat{} = image = Evision.imread(
Path.join([__DIR__, "testdata", "back.jpg"]),
flags: Evision.Constant.cv_IMREAD_GRAYSCALE())
%{image: Evision.Mat.as_type(image, :s32)}
end

describe "functions from base class Evision.Face.FaceRecognizer is available in sub-classes" do
test "Evision.Face.EigenFaceRecognizer.t()", %{image: image} do
module = Evision.Face.EigenFaceRecognizer
face_recogniser = module.create()
face_recogniser = module.train(face_recogniser, [image], Nx.tensor([0], type: :s32))
assert face_recogniser.__struct__ == module
end

test "Evision.Face.FisherFaceRecognizer.t()", %{image: image} do
module = Evision.Face.FisherFaceRecognizer
face_recogniser = module.create()
face_recogniser = module.train(face_recogniser, [image, image], Nx.tensor([0, 1], type: :s32))
assert face_recogniser.__struct__ == module
end

test "Evision.Face.LBPHFaceRecognizer.t()", %{image: image} do
module = Evision.Face.LBPHFaceRecognizer
face_recogniser = module.create()
face_recogniser = module.train(face_recogniser, [image], Nx.tensor([0], type: :s32))
assert face_recogniser.__struct__ == module
end
end
end

0 comments on commit 1a12402

Please sign in to comment.