If I'm not mistaken, you want to resize the video frames with the same size of imgTarget
You can solve with two-steps
-
- Check whether the video is opened
-
- If the video is opened then
resize
First you should be checking whether your video can be opened
h,w,c = imgTarget.shape #burada resmimizin yüksekliğini, kalınlığını genişliğini falan alıyoruz.
while Vid.isOpened():
success, Video = Vid.read()
Now you need to check whether the current frame returns
h,w,c = imgTarget.shape #burada resmimizin yüksekliğini, kalınlığını genişliğini falan alıyoruz.
while Vid.isOpened():
success, Video = Vid.read()
if success:
Now resize
h,w,c = imgTarget.shape #burada resmimizin yüksekliğini, kalınlığını genişliğini falan alıyoruz.
while Vid.isOpened():
success, Video = Vid.read()
if success:
Video = cv.resize(Video, (w, h))
If you want to display you can use imshow
h,w,c = imgTarget.shape #burada resmimizin yüksekliğini, kalınlığını genişliğini falan alıyoruz.
while Vid.isOpened():
success, Video = Vid.read()
if success:
Video = cv.resize(Video, (w, h))
cv2.imshow("Video")
key = cv2.waitKey(1) & 0xFF
# if the `q` key was pressed, break from the loop
if key == ord("q"):
break
Make sure to release the cap
and Vid
variables at the end of the code.
h,w,c = imgTarget.shape #burada resmimizin yüksekliğini, kalınlığını genişliğini falan alıyoruz.
while Vid.isOpened():
success, Video = Vid.read()
if success:
Video = cv.resize(Video, (w, h))
cv2.imshow("Video")
key = cv2.waitKey(1) & 0xFF
# if the `q` key was pressed, break from the loop
if key == ord("q"):
break
Vid.release()
cap.release()