DrewNF / Tensorflow_Object_Tracking_Video

Object Tracking in Tensorflow ( Localization Detection Classification ) developed to partecipate to ImageNET VID competition
MIT License
502 stars 198 forks source link

can not open a mp4 video #8

Open PapaMadeleine2022 opened 7 years ago

PapaMadeleine2022 commented 7 years ago

hello, firstly, I find that your code have import error. The reason should be that the names are not uniform between Utils_Video.py and utils_video.py or Utils_Image.py and utils_image.py. Please check it.

Importantly, I run python VID_yolo.py --path_video xxx.mp4, but it shows error:

Opening File Video:2.mp4 
could Not Open : 2.mp4
Traceback (most recent call last):
  File "VID_yolo.py", line 120, in <module>
    main()
  File "VID_yolo.py", line 108, in main
    frame_list, frames = utils_video.extract_frames(args.path_video, args.perc)
TypeError: 'NoneType' object is not iterable

why can not open a mp4 file? can you give some advises?

MTRNord commented 7 years ago

Even I am not the maintainer but maybe it is this issue? https://stackoverflow.com/questions/13834399/cannot-open-mp4-video-files-using-opencv-2-4-3-python-2-7-in-windows-7-machi

MTRNord commented 7 years ago

Or https://stackoverflow.com/questions/31040746/cant-open-video-using-opencv Telling from everything google would have told you it propably is a missing ffmpeg or openCV build against the wrong ffmpeg

PapaMadeleine2022 commented 7 years ago

@MTRNord thank for your reply. rebuild ffmpeg and opencv did not work. But a workaround

import sys
import skvideo.io
cap = skvideo.io.VideoCapture(sys.argv[1])
ret, frame = cap.read()

works for me. but another error:

Opening File Video:1.mp4 
Opened File Video:1.mp4 
Start Reading File Video:1.mp4 
Traceback (most recent call last):
  File "VID_yolo.py", line 120, in <module>
    main()
  File "VID_yolo.py", line 108, in main
    frame_list, frames = utils_video.extract_frames(args.path_video, args.perc)
  File "/home/ztgong/work/video/objectTracking/Tensorflow_Object_Tracking_Video/utils_video.py", line 472, in extract_frames
    total = int((vidcap.get(cv2.CAP_PROP_FRAME_COUNT)/100)*video_perc)
  File "/home/ztgong/local/anaconda2/lib/python2.7/site-packages/skvideo/io/__init__.py", line 109, in get
    raise NotImplementedError()
NotImplementedError
av_interleaved_write_frame(): Broken pipe
    Last message repeated 1 times

can you give some advises?

DrewNF commented 7 years ago

Yes exactly! The project was running without error when I uploaded it. During the development I had to check many times the frames extraction, because there are plenty method and all of them have compile error or library dependencies that was missing. Please check carefully if you miss some dependencies! Bests

PapaMadeleine2022 commented 7 years ago

@DrewNF OK, thank you.

PapaMadeleine2022 commented 7 years ago

@DrewNF how to fix the problem I described above?

DrewNF commented 7 years ago

The problem comes from the cv2.blablabla parameter, is the one that, also in the project, can raise problem, because dependently on the library and how you install it, you have to cast it like cv2.cv.blablabla. You have to search the specific solution, googling the error, you will save time and fine a specific solution! Best

PapaMadeleine2022 commented 7 years ago

@DrewNF as the error:

Traceback (most recent call last):
  File "VID_yolo.py", line 120, in <module>
    main()
  File "VID_yolo.py", line 108, in main
    frame_list, frames = utils_video.extract_frames(args.path_video, args.perc)
  File "/home/ztgong/work/video/objectTracking/Tensorflow_Object_Tracking_Video/utils_video.py", line 472, in extract_frames
    total = int((vidcap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)/100)*video_perc)
AttributeError: 'module' object has no attribute 'cv'

I change the total = int((vidcap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)/100)*video_perc) to total = int((vidcap.get(cv2.CAP_PROP_FRAME_COUNT)/100)*video_perc) The number seems to not be same for cv2.cv.CV_CAP_PROP_FRAME_COUNT and cv2.CAP_PROP_FRAME_COUNT. But now cv2 has no cv. So what should I use to replace cv2.cv.CV_CAP_PROP_FRAME_COUNT?

DrewNF commented 7 years ago

You cast as I suggested, but is better that u search your previous error and try to find solutions​for it 😁 because dependently on you install libraries you have to cast the parameter!

sfarkya commented 6 years ago

@IvyGongoogle Did you work around the problem you were facing regarding cv2.cv.CV_CAP_PROP_FRAME_COUNT issue?

DrewNF commented 6 years ago

The error is given because he cannot match the casting of the CV library installed, that why. To solve it u need a simple online research of the error output.