EVP 简介
(Effective Image and Video Processing toolbox for scilab)
EVP是Scilab Aurora的一个子项目.
顾名思义EVP是一个图像与视频处理的一个更有效的工具箱。在图像读写上用了OpenCV,在视频读写上用了FFmpeg。其它的图像变换及滤镜出于郊率考虑,都用Scilab脚本及自己的C接口实现.
#1、使用libvideo:
in = video_open( filename );
[frame_rate, frame_num] = video_info( in );
img = video_read_frame( in );
// do something with the image ...
video_close(in);
// or: video_close_all();
out = video_open_w( filename, bit_rate, width, height, frame_rate );
// prepare img with size width*height ...
video_write_frame( img, out);
video_close_w( out);
// or :video_close_all_w();
这里是一个视频格式转化的例子:
in = video_open( 'ww.mpg');
out = video_open_w ('out.swf', 400000, 352, 288, 25);
[frame, num ] = video_info(in)
for i=1:num
im = video_read_frame(in);
video_write_frame( im, out );
end
video_close_w( out );
video_close(in);
#2, 使用 libimg:
img = imread( filename );
imwrite( img, filename );
#3, 使用 libimdraw & libtimer
imdraw(img, 0, dst_x, dst_y, dst_w, dst_h );
imshow(img);
t1 = time();
// do something
time()-t1
sleep( millonseconds );
一个例子: 简单的播放器
(出于演示,这里只是Window版的,看demos/player.sce有Linux 与Windows 都能正常运行的全代码)
in = video_open( 'ww.mpg');
[frame, num ] = video_info(in)
for i=1:num
im = video_read_frame(in);
sleep(30);
imdraw(im, 0, 0,0,352, 288);
end
video_close(in);
#4, 使用Resize, rotate
im = imread("lena.png");
img=Rotate(im,30);
#5, 给图像增加滤镜
一个给图像加上马赛克效果的例子:
// add filter: mosaic
img = Mosaic(im,8);
// show the effect
imshow(img);
我们参考了SIVP的代码(但没有直接使用),还是感谢他们(http://sivp.sourceforge.net/).
我们的优点:
1,支持几乎所有的视频格式:
我们用了一流的视频编码与解码库FFmpeg. 下面是其官方网的简介:
FFmpeg is a complete solution to record, convert and stream audio and video. It includes libavcodec, the leading audio/video codec library.
FFmpeg是一个迷人的库.使用它,我们可以打开很多的格式,而又不用考虑系统的不同,(当然在Windows下编译与使用FFmpeg是一个恶梦,不过我们为你做完了.^_^)还是去http://ffmpeg.mplayerhq.hu/ 了解更多.
2,读写视频的速度让人满意.
不用VFW了,一个MS的过时的库,效率很让人怀疑.(SIVP在Winodws下通过OpenCV使用VFW,是让我们自己实现EVP的根源)
3,高效的显示:
不同与一般的方法,把图像转化为TCL/Tk可以认识的ppm格式,再通过TCL/TK显示出来.这个方法是跨平台的,但是慢得惊人,明显是不能让我们满意. 我们自己写了C接口,在Windows下用Win32 API显示,在Linux 下用xlib 与gdk-pixbuf来显示图像. 实践证明我们的努力是有效的,至少更适用于Scilab Aurora.
4,图像变换及滤镜出于郊率考虑,都用Scilab脚本及自己的C接口实现.
这样就省去了很多用与格式转化的开销.
5,更方便的安装与使用,做了有界面的安装包,其中有用到的库,所以可以直接使用了.
不足:
1,OpenCV更偏于计算机视觉,可能用Image Magic来处理图像可以会更好.
2,imshow的实现不是很好,直接画在屏上了.
先感谢我们组员杨开贵的测试与二进制安装包的制做.
我们在Winodws, Ubuntu, Debian 和FC5.下测试通过.
手工安装:
(Winodws)解压到$SCILAB/contrib
(Linux)解压到$SCILAB/contrib, 然后mv libs/* $SCILAB/libs
注意:
在FC5下,若导入有问题,执行:
chcon -t texrel_shlib_t $SCILAB/libs/*
若有其它的系统,可以重新编译:
EVP使用了OpenCV,与FFmpeg所以, 确保你先安装了它们.
前面说了imdraw 是实现, 所以在Linux下要先有: xlib and gdk-pixbuf-2.0.
在Windows下编译FFmpeg是一个恶梦,想试一下的话可以看看src各目录下的note.txt的说明.
其它的好办一点.
Good Luck.
Scilab >= 4.0 (http://www.scilab.org/)
Xlib & gdk-pixbuf-2.0 (Linux)
(We include these libraries in binary version. But if you want to install from source, install those libraries first.)
OpenCV >= 0.9.6 (http://sourceforge.net/projects/opencvlibrary/)
FFMPEG >= 0.4.9 (http://ffmpeg.sourceforge.net/)
作者:
江逢斌 <jonbo@126.com>
- Wrote video I/O, image I/O, imdraw, libtimer
杨开贵 <justforward.xm@gmail.com>
- filters, and EVP Linux port and GUI installer
周细岳 <zxy_0725@163.com>
- resize and rotate
Scilab Aurora 小组
主页: http://scilab-aurora.sourceforge.net/
常见问题:
在FC5下,若导入有问题,执行:
chcon -t texrel_shlib_t $SCILAB/libs/*
计划:
改进 imshow