1

我在 lubuntu 12.10 上使用 python 2.7.3 运行 python 脚本时遇到问题,它通过英特尔处理器的旧 mac 书(2009 年夏季,可能是 5,2 型)上的虚拟盒运行。

该脚本似乎检测到我通过命令行指定的视频文件,但我不确定出了什么问题。这是追溯以及导致错误的代码和代码。

1

src_dir = sys.argv[1]
out_dir = sys.argv[2]
bb_dir = sys.argv[3]
vid_name = sys.argv[4]

vid_src_name = src_dir + vid_name
vid_dest_name = out_dir + vid_name
vid_bb_name = bb_dir + vid_name

vid=video.asvideo(vid_src_name,down_factor)

2

if hasattr(video_source, 'shape') and hasattr(video_source, 'dtype'):
    if len(video_source.shape) == 3:
        video_source.shape = video_source.shape + (1,)

    vshape = video_source.shape
    vdtype = video_source.dtype
    vid = Video(frames=vshape[0], rows=vshape[1], columns=vshape[2], bands=vshape[3], dtype=vdtype, initialise=False)
    vid.V = video_source
    return vid

if not os.path.exists(video_source):
    raise IOError(video_source + ' not found')

    (unusedfh,sample_filename) = tempfile.mkstemp()
 cmd = 'ffmpeg -i "' + video_source + '" -vframes 1 ' + sample_filename+'    %d' + image_ext + ' 2> /dev/null > /dev/null'
 sample_filename = sample_filename + '1' + image_ext
 subp.call(cmd, shell = True)
 sample_img = sp.misc.imread(sample_filename)

3.

 im = Image.open(name)

4.

 if mode != "r":
     raise ValueError("bad mode")

 if isStringType(fp):
     import __builtin__
     filename = fp
     fp = __builtin__.open(fp, "rb")

输出:

cody@cody-VirtualBox:~/Dropbox/annotation/Template_Extractor$ python        template_extract_new.py "/home/cody/Work/annotate/UCF50/video/PushUps"     "/home/cody/Dropbox/annotation/template/Pushups" "/home/cody/Dropbox/annotation/bb/PushUps" "/v_PushUps_g01_c01.avi"
Traceback (most recent call last):
  File "template_extract_new.py", line 192, in <module>
    vid=video.asvideo(vid_src_name,down_factor)
  File "/home/cody/Dropbox/annotation/Template_Extractor/istare/video.py", line 135, in   asvideo
    sample_img = sp.misc.imread(sample_filename)
  File "/usr/lib/python2.7/dist-packages/scipy/misc/pilutil.py", line 102, in imread
    im = Image.open(name)
  File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1952, in open
    fp = __builtin__.open(fp, "rb")
IOError: [Errno 2] No such file or directory: '/tmp/tmpklcTe61.bmp'

错误中指示的文件每次都会更改,并且在运行之前不存在,但在运行命令后存在。

我试过从 uterm、uxterm 和 lxterminal 运行(知道它不会做任何事情,但无论如何都要尝试,而且在 uterm 中没有复制和粘贴)。

4

0 回答 0