VATIC在线视频注释工具 VATIC 安装教程 Git Hub地址

VATIC是一个用于计算机视觉研究的在线视频注释工具,它将工作众包给亚马逊的Mechanical Turk。我们的工具可以轻松构建大规模,经济实惠的视频数据集。

1. 安装并启动

拉取vatic镜像 docker pull jldowns/vatic-docker-contrib

运行镜像 docker run -it -d --name vatic -p 8898:80 -p 8899:3306 docker.io/jldowns/vatic-docker-contrib:latest

修改配置文件config.py中IP地址 localhost = "http://所在ip:prot/"

配置mysql可远程访问的 vi /etc/mysql/my.cnf

修改属性值bind-address = 0.0.0.0

启动MySQL和Apache服务 /home/vagrant/start_services.sh

数据库账号密码 /home/vagrant/vatic/config.py

登录mysql mysql -uroot -phail_ukraine

设置可远程访问权限及远程登录密码 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

可根据需求修改以下文件

如:新增导出json数据 /home/vagrant/vatic/cli.py

第990行部分代码-仅供参考
annotation = {}
annotation["image"] = "{0}.jpg".format(strframe)
object = {}
object["vehicleId"] = track.paths[0].id
object["label"] = track.label
object["xmax"] = box.xbr
object["xmin"] = box.xtl
object["ymax"] = box.ybr
object["ymin"] = box.ytl
object["difficult"] = difficult
object["occluded"] = box.occluded
object["pose"] = "Unspecified"
object["truncated"] = 0
annotation["object"] = object
annotations.append(annotation)

如:固定图片尺寸 /home/vagrant/vatic/cli.py

第55行
image = image.resize((args.width, args.height), Image.ANTIALIAS)
源代码是按比例缩放
image.thumbnail((args.width, args.height), Image.BILINEAR)

2. 抽取图片

从视频抽取目标图片集合, 内部使用了ffmpeg

默认是720x480的目标分辨率,也可以添加--no-resize来保证原图的图片质量

cd /home/vagrant/vatic
turkic extract /home/vagrant/vagrant_data/your_video.mp4 /home/vagrant/vagrant_data/your_video_frames/
可以通过width和height指定自己想要的尺寸:
turkic extract /home/vagrant/vagrant_data/your_video.mp4 /home/vagrant/vagrant_data/your_video_frames/ 
--width 800 --height 600

(不执行这一步好像也可以)如果你已经将视频抽取为帧,可以使用如下命令讲其转化为vatic使用的格式

turkic formatframes /home/vagrant/vagrant_data/your_video_frames /home/vagrant/vagrant_data/vatic_video_frames/

3. 将图片load到数据库

载入视频帧文件夹,为该标注任务设置一个job_id(数据库名称),并指定标注的label(标注类型如:car bus person):

turkic load job_id /home/vagrant/vagrant_data/your_video_frames Label1 Label2 Label3 --length 3000 --offline

--length 此视频的每个片段的长度(以帧为单位) 更多选项请查看看官方文档

4. 发布任务

发布任务,离线在本地发布任务:

turkic publish --offline

执行上一条命令会返回每一段任务的URL:

http://localhost/?id=1&hitId=offline
http://localhost/?id=2&hitId=offline
http://localhost/?id=3&hitId=offline
http://localhost/?id=4&hitId=offline
http://localhost/?id=5&hitId=offline

5. 导出元数据或视频

dump标注后的元数据,结束标注并保存后使用如下命令将标注结果导出

turkic dump job_id -o /home/vagrant/vagrant_data/annotations --pascal --pascal-skip 1

vatic支持以下保存格式,可以在保存时指明自己想要的格式,默认txt,例如常用的pascal格式,--pascal-skip用来指定相隔多少帧保存一次数据,默认是15帧。

--xml       Use XML
--json      Use JSON
--matlab    Use MATLAB
--pickle    Use Python's Pickle
--labelme   Use LabelMe video's XML format
--pascal    Use PASCAL VOC format, treating each frame as an image

dump标注后的图片数据

turkic visualize job_id $output_path --merge --no-augment

cd $output_path

ffmpeg -i %d.jpg -vcodec mpeg4 output.avi

支持导出带标注box的图片集合,并可以通过ffmpeg合成为一段完成的演示视频

6. 常用命令

1. 列出所有视频

检索系统中所有视频的列表:turkic list

如果您只想要发布的视频:turkic list --published

如果您只想要处理过的视频:turkic list --completed

如果您想要用于黄金标准的视频:turkic list --training

最后,如果您只想计算系统中有多少视频,请使用--count选项,结合以上任何一项:

turkic list --count

turkic list --published --count

如果您需要有关每个视频的统计信息,请提供--stats选项:

turkic list --stats

查找指定job的视频

turkic find --id job_id

2. 删除视频

删除指定任务视频 turkic delete job_id

视频已注释,可以强制删除:turkic delete identifier --force

重新重启数据库:(不过你之前的标注就没有了,谨慎使用)

turkic setup –-database -–reset