[Scilab-users] Converting a figure to a SciCV Mat

Tan Chin Luh chinluh at tritytech.com
Sat Jul 27 18:08:56 CEST 2019


Hi,

While I think to create animation to animated gif is the most effective 
way to share the animation, another alternative you could look at is 
using the IPCV to create a movie from it.

Please find below for the sample codes:

_________________
tic();

// open a file for write
n = avifile('test.avi', [640;480], 30,'xvid');

// Initiate plot and get the handle
plot(rand(100,1));
e = gce();

scf(0)

// run 100 frame random data
for cnt = 1:100
     new_data = rand(100,1); // new data
     e.children.data(:,2) = new_data;   // replace new data onto current 
plot
     im = xs2im(0);  // get the plot into a matrix
     addframe(n, im);    // add the matrix/frame into the file
end
aviclose(n);

disp(toc());
____________________

Still, the function "xs2im" will still create the intermediate file in 
the temp folder as like animaGIF. The above 100 frames took about 6s in 
i5 computer.

In this case, you could control the resolution of the video, and also 
the frame rate of the video.

Thanks.

Chin Luh

On 27/7/2019 1:52 AM, Samuel Gougeon wrote:
> Hello,
>
> Le 26/07/2019 à 19:22, stevenrjarrett a écrit :
>> Is there a way to convert a Scilab figure to a SciCV Mat? I had thought the
>> simplest way would be to convert the figure to a matrix and use the matrix
>> data to create the SciCV Mat, but I have not been successful finding a way
>> to do either.
>>
>> The reason I want to convert between them is so that I can create a video
>> that shows data being plotted in real time. I have done this successfully by
>> creating the figures, writing a series of image files, and converting the
>> images to a video using the SciCV toolbox. As you can imagine, it is time
>> consuming to write that many images to the disk as only an intermediate
>> step, and I have been trying to find a cleaner/faster way to do it within
>> Scilab.
>
> If you are really in a hurry, i am afraid that you will have to find 
> an external solution, because anyway exporting figures within Scilab 
> is quite slow, even in bitmap encodings. This has been reported here 
> <http://bugzilla.scilab.org/13904> and is still the case.
>
> Otherwise, you can use animaGIF(), that can avoid storing all 
> intermediate images, but that does not avoid creating them. So, it 
> saves disk space, but not time as you request. It does not really aim 
> to make video with a "normal" frame rate, although it can mimik it.
>
> Samuel
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20190728/b5766e2d/attachment.htm>


More information about the users mailing list