Exception: 'dlib.mmod_rectangle' object has no attribute 'right' - 例外:'dlib.mmod_rectangle'对象没有属性'ri...

本文解决了在使用dlib进行面部检测时遇到的'dlib.mmod_rectangle'对象没有'right'属性的问题。详细解释了cnn版本的dlib返回的是mmod_rectangle类实例,而非简单矩形,并提供了正确获取矩形点的方法。
摘要由CSDN通过智能技术生成

I'm using dlib for face detection and getting this error

Exception:  'dlib.mmod_rectangle' object has no attribute 'right'

What is the problem? I'm using cnn version of dlib which should run on gpu and here is the code

detector = dlib.cnn_face_detection_model_v1('mmod_human_face_detector.dat')
img = dlib.load_rgb_image(img_path)
dets = detector(img, 1)

Solution 1

If you use cnn version of dlib, it does not return you simple rectangle. It returns you an instance of a class, which have the rectangle inside of it.

class dlib.mmod_rectangle:
  # Wrapper around a rectangle object and a detection confidence score.
  confidence
  rect

This is the definitation of the class. it has a field rect, where you can find your points. http://dlib.net/python/index.html#dlib.mmod_rectangle

 

aipool: https://ai-pool.com/d/exception____dlib_mmod_rectangle__object_has_no_attribute__right_

转载于:https://www.cnblogs.com/hazarapet/p/10776014.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值