python watchdog的使用_用Python中的Watchdog处理图像

我使用watchdog库来检测在特定文件夹中创建新图像的时间。当watchdog检测到新创建的图像时,我使用SimpleCV/OpenCV启动一些图像处理功能。在

然而,这些照片是从一个树莓派相机拍摄的,从下面的错误我不相信整个图像是保存时,它第一次出现在目录中。(实际上,文件是以“碎片”或多种形式保存的)。在

请注意当我将图像复制并粘贴到相应的文件夹中时,脚本将成功运行。在

询问:是否有任何方法可以仅在保存完整个文件后才启动图像处理?在import time

from SimpleCV import Image

from watchdog.observers import Observer

from watchdog.events import FileSystemEventHandler

class ExampleHandler(FileSystemEventHandler):

def on_created(self, event):

image = Image(event.src_path)

do image processing stuff

print "Got event for file %s" % event.src_path

observer = Observer()

event_handler = ExampleHandler() # create event handler

observer.schedule(event_handler, path='/path/to/images') # set observer to use created handler in directory

observer.start()

# sleep until keyboard interrupt, then stop + rejoin the observer

try:

while True:

time.sleep(1)

except KeyboardInterrupt:

observer.stop()

observer.join()

错误转储:

^{pr2}$

编辑在识别一个新文件后将处理程序更新到休眠状态几秒钟后,我收到一个不同的错误。在class ExampleHandler(FileSystemEventHandler):

def on_created(self, event):

time.sleep(3)

cans = Image(event.src_path)

错误IOError: [Errno 2] No such file or directory: '/path/to/images/test.jpg~'

请注意,我使用以下Pi命令捕获图像:raspistill -o 'test.jpg'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值