paul-pias / Object-Detection-and-Distance-Measurement

Using yolov3 & yolov4 weights objects are being detected from live video frame along with the measurement of the object from the camera without the support of any extra hardware device.
348 stars 118 forks source link

RuntimeError: typeerror: expected PRT <cv::umat> for argument 'src' #9

Closed QuanLI-21 closed 4 years ago

QuanLI-21 commented 4 years ago

Hi, When I tried to run the code "object_detection.py" for a video. I am able to read the video, resize it. There was a error: TypeError: Expected cv::UMat for argument 'src', line:"frame = cv2.resize(frame,(self.width, self.height))"

I am using opencv 4.2.0 on python 3.7. I guess it may be because of version. Which Pytorch Version you are using? Thanks!

paul-pias commented 4 years ago

Thank you for reaching out. My python version is 3.6.8 and opencv-python version is 4.2.0.32. There is no such error on my side. Kindly let me know if changing the version resolves your error or not.

nikoststs commented 4 years ago

I am having exactly the same issue as @LiQuan19 . It seems like it doesnt recognize the input video?

paul-pias commented 4 years ago

@nikoststs Can you kindly mention your opencv and python version?

QuanLI-21 commented 4 years ago

Hi, I have solved this problem, it should not be a version problem, I changed the "frame = self.cap.read()" to "ret, frame = self.cap.read()" in the section of "def main(self)". "self.cap.read()"can return two parameters. @nikoststs .Thanks @paul-pias

nikoststs commented 4 years ago

I followed LiQuan19 solution and it did work for me as well. @paul-pias , i do have another question though. Is there an output video file that shows the distances being measured and the bboxes? ( if it is better to move it to a new question, please do tell me )

paul-pias commented 4 years ago

@nikoststs @LiQuan19 Thank you for your cooperation. I will add this in the code segment for future reference.