Django上由<function wrapper =“”at =“”0x7f2f82ee3aa0 =“”>启动的线程中未处理的异常

时间:2017-08-04 07:45:24

标签: django opencv3.1

在Django中传递models.py中的函数时发生未处理的异常(通过 pip安装 安装 numpy django < / em> 要求

  

我正在尝试使用OpenCV,Numpy和Redis在网络上操纵面部检测API   但是我在models.py

中传递了一些异常      

我只是关于Django框架和Python语言的新手。

运行我的Django服务器时出现错误!

  

由。开始的线程中未处理的异常   追溯(最近的呼叫最后):
  文件&#34; /home/xyz/.xyz/lib/python2.7/site-packages/django/utils/autoreload.py" ;,第227行,在包装纸中        fn(* args,** kwargs)
  文件&#34; /home/xyz/.xyz/lib/python2.7/site-packages/django/core/management/commands/runserver.py",第117行,在inner_run中autoreload.raise_last_exception()
  文件&#34; /home/xyz/.xyz/lib/python2.7/site-packages/django/utils/autoreload.py" ;,第250行,在raise_last_exception中     six.reraise(* _除外)
  文件&#34; /home/xyz/.xyz/lib/python2.7/site-packages/django/utils/autoreload.py" ;,第227行,在包装纸中      fn(* args,** kwargs)
    文件&#34; /home/xyz/.xyz/lib/python2.7/site-packages/django/ init .py&#34;,第27行,在设置中     apps.populate(settings.INSTALLED_APPS)
  文件&#34; /home/xyz/.xyz/lib/python2.7/site-packages/django/apps/registry.py" ;,第108行,填写中      app_config.import_models()
    文件&#34; /home/xyz/.xyz/lib/python2.7/site-packages/django/apps/config.py",第202行,在import_models中     self.models_module = import_module(models_module_name)
    文件&#34; /usr/lib/python2.7/importlib/ init .py&#34;,第37行,在import_module 导入(名称)
   文件&#34; /home/xyz/PycharmProjects/xyz_project/OpencvWeb/opencv_api/Face_detection/models.py" ;,第28行,中
     LFace类:
     文件&#34; /home/xyz/PycharmProjects/xyz_project/OpencvWeb/opencv_api/Face_detection/models.py" ;,第29行,在LFace中       def init (self,faceRect = LRect(),eyes = [],id = 0,mt = 0,vel = LVector(0,0)):
  NameError:name&#39; LRect&#39;未定义

这是我在models.py中的代码 这是LFace的课程

class LFace:
    def __init__(self, faceRect = LRect(), eyes=[], id = 0, mt = 0, vel = LVector(0,0)):
        self.face = faceRect.clone()
        self.eyes = [e.clone() for e in eyes]
        self.id = id
        self.name = ''
        self.missingTicks = mt
        self.velocity = vel
    def clone(self):
        return LFace(self.face, self.eyes, self.id)
    def setAs(self, f2):
        self.face = f2.face.clone()
        self.eyes = [e.clone() for e in f2.eyes]
        self.id = f2.id
        self.missintTicks = f2.missingTicks
        self.velocity = f2.velocity.clone()
    def dist(self, f2, scalar1 = 1.0, scalar2 = 0.2):
    #distance is defined as: center differences * scalar1 + size differences * scalar2
        d1 = self.face.center().dist(f2.face.center())
        d2 = self.face.wh().dist(f2.face.wh())
        return d1 * scalar1 + d2 * scalar2
    def interpolateTo(self, f2, t):
        self.face.interpolateTo(f2.face, t)
        self.eyes = f2.clone().eyes if t > 0.5 else []
    def getPredicted(self):
        rv = self.clone()
        p = rv.face.center()
        oldP = p.clone()
        p += self.velocity
        rv.velocity = LVector(0,0)
        rv.face.setFromCenter(p)
        return rv  

这是LRect的课程

class LRect:  
        def __init__(self, x=0, y=0, w=0, h=0):
            self.x = x
            self.y = y
            self.w = w
            self.h = h

        def pos(self):
            return LVector(self.x, self.y)

        def wh(self):
            return LVector(self.w, self.h)

        def hwh(self):
            return LVector(self.w, self.h) * 0.5

        def center(self):
            return (self.pos() + self.hwh())

        def toString(self):
            return '[x={0},y={1},width={2},height={3}]'.format(*self.toList())

        def __str__(self):
            return self.toString()

        def toList(self):
            return [self.x, self.y, self.w, self.h]

        def clone(self):
            return LRect(self.x, self.y, self.w, self.h)

        def setFromCenter(self, centerPoint):
            hp = self.hwh()
            self.x = centerPoint[0] - hp[0]
            self.y = centerPoint[1] - hp[1]

        def scaleWH(self, scalar):
            # scalar can be either an LVector or a number
            c = self.center()
            hwh = self.wh() * scalar
            self.w, self.h = hwh[0], hwh[1]
            self.setFromCenter(c)

        def interpolateTo(self, r2, t):
            c = self.center()
            wh = self.wh()
            c.interpolateTo(r2.center(), t)
            wh.interpolateTo(r2.wh(), t)
            self.w, self.h = wh[0], wh[1]
            self.setFromCenter(c)
  

请帮助!!

0 个答案:

没有答案