如何从Matlab移植到Web的Headless Octave [英] How to port from Matlab to Headless Octave for Web

查看:80
本文介绍了如何从Matlab移植到Web的Headless Octave的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我编写的Matlab应用程序,希望放在运行Octave的AWS服务器上,以使服务可以通过Web公开使用.我从没用过八度音阶.

I have a Matlab application that I wrote and would like to put on a AWS server running Octave to make a service publicly available via the web. I've never used Octave.

我已经读过"--no-window-system"将使我无头运行,而且我知道我可以使用"saveas(fig,FileName,format)"保存我的图形.我的问题是,在Octave中,plot()和histogram()是否可以正常工作,如果可以的话,我该如何处理? (我希望这些数字转到将在网页中引用的gif或jpeg.)

I've read that the "--no-window-system" will allow me to run headless, and I know that I can use "saveas(fig,FileName,format)" to save my figures. My question is will plot() and histogram() work without a head in Octave, and if so how do I go about this? (I want the figures to go to gifs or jpegs that I'll reference in a web page.)

TIA

推荐答案

从理论上讲,它应该可以正常工作.

In theory it should work as expected.

请记住以下内容并尝试解决:

Things to keep in mind and try to work around include the following:

  1. 如果您的环境未提供X DISPLAY,则仅gnuplot图形工具包将可用.如果您想伪装" x显示以允许使用其他图形工具包(例如graphics_toolkit('qt')),请考虑通过xvfb-run运行八度,它模拟了一个哑" x服务器. (即以xvfb-run octave的形式启动八度,请参见 https://bugs. debian.org/cgi-bin/bugreport.cgi?bug=805295 ).

  1. If your environment does not provide an X DISPLAY, only the gnuplot graphics toolkit will be available. If you'd like to 'fake' an x display to allow you use of other graphics toolkits (e.g. graphics_toolkit('qt')), consider running octave via xvfb-run, which simulates a 'dumb' x server. (i.e. launch octave as xvfb-run octave, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=805295 ).

有时,当您尝试绘制屏幕外"内容时,OpenGl会抱怨.如果您的图像默认设置为不可见,则可以解决此问题,这仍然允许打印图像而不必出现在屏幕上.为此,在绘制任何东西之前,将根"图形对象设置为不可见:

Occasionally OpenGl complains when you try to plot things that are 'offscreen'. This problem can be worked around if your images are set to non-visible as default, which still allows them to be printed without necessarily appearing on screen. To do this, set the 'root' figure object to non-visible before plotting anything:

set(0, 'defaultfigurevisible', 'off')

具体来说,您的代码可能如下所示:

Concretely, your code might look like this:

gnuplot_toolkit('qt';)   # optional, if run via xvfb-run or the AWS supports an X Display
set(0, 'defaultfigurevisible', 'off');
h = plot( 1 : 10 );
saveas( h, 'out.png', 'png' ); # you can replace 'png' with 'gif' or 'jpg' etc.

这篇关于如何从Matlab移植到Web的Headless Octave的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆