A series of convenience functions to make basic image processing operations such as translation, rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV and Python.
MIT License
4.51k
stars
1.03k
forks
source link
AttributeError: 'NoneType' object has no attribute 'shape' #217
So I was working on this code for social distancing detection using AI and I am consistently getting an error in line 18. Kindly help me with this.
`import numpy as np
import time
import cv2
import math
The error is:
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
16 hasFrame, frame = cap.read()
17 net = cv2.dnn.readNetFromDarknet(configPath, weightsPath)
---> 18 vid_writer = cv2.VideoWriter('output.mp4',cv2.VideoWriter_fourcc('M','J','P','G'), 10, (frame.shape[1], frame.shape[0]))
19
20
AttributeError: 'NoneType' object has no attribute 'shape'`
Please help me with this. According to me, the error is in the shape which I am using.
So I was working on this code for social distancing detection using AI and I am consistently getting an error in line 18. Kindly help me with this. `import numpy as np import time import cv2 import math
labelsPath = "./coco.names" LABELS = open(labelsPath).read().strip().split("\n")
np.random.seed(42) COLORS = np.random.randint(0, 255, size=(len(LABELS), 3), dtype="uint8")
weightsPath = "./yolov3.weights" configPath = "./yolov3.cfg" cap = cv2.VideoCapture('./videos/example.mp4') hasFrame, frame = cap.read() net = cv2.dnn.readNetFromDarknet(configPath, weightsPath) vid_writer = cv2.VideoWriter('output.mp4',cv2.VideoWriter_fourcc('M','J','P','G'), 10, (frame.shape[1], frame.shape[0]))
while cv2.waitKey(1) < 0:
vid_writer.release() cap.release() cv2.destroyAllWindows()`
The error is: `--------------------------------------------------------------------------- AttributeError Traceback (most recent call last)