繁体   English   中英

使用PIL逐帧分析视频

[英]Using PIL to analyze a video frame by frame

我正在使用PIL对视频分区中的像素强度进行平均。 我想做的是:

-使用ffmpeg将视频分成几帧
-使用PIL在每个框架中选择一个窗口(这是我需要帮助的步骤)
-在每一帧的窗口上进行某种分析,然后汇总数据(例如平均颜色与时间的对比)

我对如何执行中间步骤很困惑-有人有建议吗?

使用Tkinter找到了一个解决方案:

import Tkinter
import Image, ImageDraw, ImageTk

window = Tkinter.Tk()
window.title('Calcium Imaging Software')

mouse_X = 0
mouse_Y = 0
ellipseBox = []
listOfCircles = []

#stuff to set up the image
image = Image.open("test.jpg")
draw = ImageDraw.Draw(image)
canvas = Tkinter.Canvas(window, width=image.size[0], height=image.size[1])
canvas.pack()
image_tk = ImageTk.PhotoImage(image)
canvas.create_image(image.size[0]//2, image.size[1]//2, image=image_tk)

#define a function to be run on the mouseclick
def drawEllipse(event):
    global ellipseBox
    print "clicked at: ", event.x, event.y
    mouse_X = event.x
    mouse_Y = event.y
    ellipseBox.append((mouse_X,mouse_Y))
    print "box corners: ",ellipseBox
    #When two corners are selected, draw the ellipse
    if len(ellipseBox) == 2:
        draw.ellipse(ellipseBox,outline=(255,255,255))
        listOfCircles.append(tuple(ellipseBox))
        ellipseBox = []
        window.update()
#bind mouse click to drawing an ellipse
canvas.bind("<Button-1>", drawEllipse)
Tkinter.mainloop()

这几乎满足了我想要的一切! 但是,我无法将椭圆形显示在图像上-有什么建议吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM