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

classic Classic list List threaded Threaded
3 messages Options
stevenrjarrett stevenrjarrett
Reply | Threaded
Open this post in threaded view
|

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

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.



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Converting a figure to a SciCV Mat

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 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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Tan Chin Luh-2 Tan Chin Luh-2
Reply | Threaded
Open this post in threaded view
|

Re: Converting a figure to a SciCV Mat

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 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
[hidden email]
http://lists.scilab.org/mailman/listinfo/users



  


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users