How do I track motion using OpenCV in Python?

后端 未结 4 1659
轮回少年
轮回少年 2020-12-01 03:03

I can get frames from my webcam using OpenCV in Python. The camshift example is close to what I want, but I don\'t want human intervention to define the object. I want to ge

4条回答
  •  死守一世寂寞
    2020-12-01 03:50

    if faces:
        for ((x, y, w, h), n) in faces:
            pt1 = (int(x * image_scale), int(y * image_scale))
            pt2 = (int((x + w) * image_scale), int((y + h) * image_scale))
            ptcx=((pt1[0]+pt2[0])/2)/128
            ptcy=((pt1[1]+pt2[1])/2)/96
            cv.Rectangle(gray, pt1, pt2, cv.RGB(255, 0, 0), 3, 8, 0)
            print ptcx;
            print ptcy;
            b=('S'+str(ptcx)+str(ptcy));
    

    This is the part of the code I tried to get the center of the moving object when tracked using a rectangular boundary.

提交回复
热议问题