Support This Project

Function list of SIVP

SIVP Doc for Scilab Contest 2006

SIVP Howto

  1. How to install SIVP under Linux?
  2. How to install SIVP under Windows
  3. How to read an image from an image file?
  4. How to write an image to an image file?
  5. How to read frames from a video file?
  6. How to read frames from a camera?
  7. How to create a video from many images

How to install SIVP under Linux?

  1. Install Scilab>=3.1.1 and OpenCV>=1.0.0. (If you want video support, OpenCV should be compiled with ffmpeg)
  2. Download SIVP source code from SourceForge and uncompress it.
  3. Run ./configure
    If configure reports some packages missed, please install them and re-run ./configure.
  4. Run make to compile the source code.
  5. Run make install as root.

How to install SIVP under Windows?

We provide a friendly graphic user interface for SIVP Windows version installation. What you do are just to run the installer program and follow the prompts.

How to read an image from an image file?

im=imread(filename);

How to write an image to an image file?

imwrite(im, filename);

How to read frames from a video file?

To read frames is very simple. What you do are just open the video file (aviopen), read frames one by one (avireadframe) and close the video file (aviclose).
  1. First you need open the video file using function aviopen. The function will return a integer number which stands for the opened video file/camera index. Not all codecs are supported by SIVP and it depends on the codecs you have installed. On Linux OpenCV must be compiled with video support and the newest version of OpenCV is recommended.
  2. SIVP can only read frames one by one using avireadframe. You can also read the f'th frame by avireadframe(n, f), but mostly the second parameter can't work and you have to read frame from the beginning of the video file.
  3. If you have opened lots of files and want to know all opened files, you can use avilistopened.
  4. At last remember to close the opened file using aviclose or avicloseall
The sample code is as follows:
n = aviopen('video.avi');
//get the first 10 frames from the video file
for f=1:10
    im = avireadframe(n);
    imshow(im);
end

avilistopened()
aviclose(n);

How to read frames from a camera?

Read frames from a camera is very similar with from a video file. The only difference is using camopen nor aviopen. Before using camera in SIVP, make sure your camera can work well.

How to create a video from many images

avifile, addframe and aviclose.
  1. You need to create a video file without frames using avifile(filename, [width;height]). The default FPS is 25 and default codec is XVID.
  2. After you successfully created the file, you can add images to it one by one using addframe. If the image size is different with the frame size specified when call avifle, the image will be resized to fit the video frame size.
  3. After you added all images, remember to close the video file using aviclose.
The sample code is as follows:
im = imread('lena.png');
n = avifile('lena.avi', [300;300], 30);

for ii=1:200
    ims = im(ii:512-ii, ii:512-ii, :);
    addframe(n, ims);
end

aviclose(n);