python围绕轴旋转图像

时间:2018-04-23 10:06:58

标签: python

我以为我找到了Idan的问题(和代码)的解决方案:

MoviePy + Vapory code

from moviepy.editor import concatenate, ImageClip, VideoClip
from vapory import *

img_path = "E:/Programming/Python/coffee.png"
img_clip = ImageClip(img_path)
W, H = img_clip.w, img_clip.h
AR = 1.0*W/H


t_rev = 2.0

t_half = t_rev/2.0  # The time required for a half revolution
t_still = 0.8 # How long (in seconds) to hold the half rotated image still



cam = Camera('location', [ 0,  0, -1],
             'look_at',  [ 0,  0,  0])
light = LightSource([0, 0, -1]) # Light at camera location
bg = Background('color', [0, 0, 0]) # Black background


def scene(t):
    """ Returns the scene at time 't' (in seconds) """
    s = Scene(camera = cam, objects = [light, bg])
    s = s.add_objects([
          Box([0, 0, 0],
              [W, H, 0],
              Texture(Pigment(ImageMap('"{}"'.format(img_path), 'once')),
                      Finish('ambient', 1.0)),
              'translate', [-0.5, -0.5, 0],
              'scale', [AR, 1, 0],
              'rotate', [0, (360/t_rev)*t, 0])]) 
    return s


def make_frame(t):
    return scene(t).render(width=W, height=H, antialiasing=0.1)


still_1 = VideoClip(make_frame).to_ImageClip(t=0).set_duration(t_still)
half_1  = VideoClip(make_frame).subclip(0, t_half)
still_2 = VideoClip(make_frame).to_ImageClip(t=t_half).set_duration(t_still)
half_2  = VideoClip(make_frame).subclip(t_half, t_rev)

final_clip = concatenate([still_1, half_1, still_2, half_2])
final_clip.write_gif("E:/Programming/Python/coffee_rot.gif", fps=15)

但是当我尝试使用Python 3.6运行它时,我得到(完全回溯): 希望这会让事情变得更清楚

 Traceback (most recent call last):
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\test2a.py", line 44, in <module>
    still_1 = VideoClip(make_frame).to_ImageClip(t=0).set_duration(t_still)
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\video\VideoClip.py", line 86, in __init__
    self.size = self.get_frame(0).shape[:2][::-1]
  File "<decorator-gen-10>", line 2, in get_frame
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\lib\site-packages\moviepy\Clip.py", line 94, in get_frame
    return self.make_frame(t)
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\test2a.py", line 41, in make_frame
    return scene(t).render(width=W, height=H, antialiasing=0.1)
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\lib\site-packages\vapory\vapory.py", line 102, in render
    quality, antialiasing, remove_temp)
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\lib\site-packages\vapory\io.py", line 106, in render_povstring
    stdout=subprocess.PIPE)
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 710, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Us\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 998, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

搜索发现类似的错误但与我的情况无关。非常感谢。 Idan你还在吗?

可以评论重新启动Windows文件路径吗?

0 个答案:

没有答案