ShiqiYu / ShiqiYu/libfacedetection
The difference between v2 and v3 version
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 12.8k
- Forks
- 3k
- PR merge metrics
- No merged PRs in 30d
Description
I compiled the v2 and v3 version code to dll and run by python and I found the result of v2 is correct but the v3 is incorrect, even the num of faces..
Below are the results.
v3

v2

the code snippet I use
# coding: utf-8
import numpy as np
import cv2
from ctypes import *
import types
import sys
if len(sys.argv) < 2:
print(
"Call this program like this:\n"
" ./ex.py ./jpg/001.jpg\n")
exit()
Max_Faces = 256
Size_one_Face = 6 + 68 * 2
Size_FaceLandMarks = Size_one_Face * Max_Faces
class FaceResults(Structure):
_fields_ = [("face_num", c_int32),
("datas", c_int16 * Size_FaceLandMarks)
]
img = cv2.imread(sys.argv[1])
h,w = img.shape[:2]
st = w*3
p_img = img.ctypes.data_as(POINTER(c_ubyte))
dll = CDLL('./dlls/facedetection_v2.dll')
dll.shiqi_fd.restype = POINTER(FaceResults)
p_results = dll.shiqi_fd(p_img,w,h,st)
face_num = p_results.contents.face_num
print(p_results.contents.datas[:Size_one_Face])
print(p_results.contents.datas[Size_one_Face:Size_one_Face*2])
for i in range(face_num):
j = Size_one_Face * i
x = p_results.contents.datas[j]
y = p_results.contents.datas[j+1]
w = p_results.contents.datas[j+2]
h = p_results.contents.datas[j+3]
confidence = p_results.contents.datas[j+4]
angle = p_results.contents.datas[j+5]
print("Face : %d ; [%d,%d]-[%d,%d] ; Conf=%d, Angle=%d"%(i,x,y,w,h,confidence,angle))
cv2.rectangle(img, (x, y), (x+w, y+h), (0,255,0), 1)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img, str(i),(x, y-10),font, 0.8, (0,0,0), 1, cv2.LINE_AA)
# show the output image
cv2.imshow("Output", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Besides, the cv2 version is 4.2.0. Am I miss something here?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the report with the provided Python ctypes snippet, cv2 4.2.0, and the same image against the v2 and v3 DLLs. Compare the shiqi_fd results, including face_num and the FaceResults datas layout, then trace the corresponding versioned library entry points. Done means the v3 output is explained and corrected or the incompatibility is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, opencv, python
- Domain
- computer-vision
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100