CV2的detectMultiScale方法返回什么?

时间:2019-01-28 10:33:27

标签: python arrays opencv cv2

在CV2中,我能够从上传的图像生成人脸。

faces = faceCascade.detectMultiScale(
    read_img,
    scaleFactor = 1.1,
    minNeighbors = 0,
    minSize=(100,100)
)
how_many_faces = len(faces)

how_many_faces 返回正确的面孔数量。

如果我将这些面孔附加到数组中...

our_faces = []
for i in faces:
    our_faces.append(i)

return str(our_faces)

...并返回 our_faces ,我得到以下数据:

  

[array([187,138,236,236],dtype = int32),array([197,138,236,236],   dtype = int32),数组([163、130、260、260],dtype = int32),数组([163,   141、260、260],dtype = int32),array([173、141、260、260],   dtype = int32),数组([184、141、260、260],dtype = int32),数组([143,   119,286,286],dtype = int32),array([167,119,286,286],   dtype = int32),数组([143、131、286、286],dtype = int32),数组([155,   131、286、286],dtype = int32),array([167、131、286、286],   dtype = int32),数组([144、105、315、315],dtype = int32),数组([157,   105、315、315],dtype = int32),array([131、118、315、315],   dtype = int32),数组([144、118、315、315],dtype = int32),数组([157,   118、315、315],dtype = int32),array([170、118、315、315],   dtype = int32),数组([130、87、346、346],dtype = int32),数组([115,   101、346、346],dtype = int32),array([130、101、346、346],   dtype = int32),数组([144、101、346、346],dtype = int32),数组([159,   101、346、346],dtype = int32),array([130、115、346、346],   dtype = int32),array([87,70,419,419],dtype = int32)]

我正确地假设此数组包含每个面孔的所有数据,并且它是一个Numpy数组吗?如果是这样,如何将数组中的数据转换回图像格式?

2 个答案:

答案 0 :(得分:3)

faceCascade.detectMultiScale()返回矩形列表,因此它不包含检测到的脸部图像,并且您不能仅从该列表中重建脸部。

如果要获取面部图像,则需要:

  • 保留您最初搜索面孔时所用图像的副本,并且
  • 使用Numpy切片或类似方法提取边界在faces返回的faceCascade.detectMultiScale()列表中的矩形

答案 1 :(得分:1)

diacritic:
  isEnabled: true
  chars[ą]: a           -> these ones could be parsed to Map<String, String>
  chars[ł]: l           
  chars[ę]: e
相关问题