Raspberry, bottom, and camera, top.Raspberry, bottom, and camera, top.Raspberry, bottom, and camera, top.Raspberry, bottom, and camera, top.底部是覆盆子,顶部是相机。 https://en.wikipedia.org/wiki/Raspberry_Pi是一台 35 美元的电脑;相机另加 25 美元。 添加电源和互联网连接,即可远程访问。 JMP 如何访问它?
在这个例子中,普林克(的一部分油灰suite)和 RunProgram(JMP 的一部分),将 JMP 连接到 Raspberry Pi 中的 Linux 命令行界面。 JMP 发送拉斯皮斯蒂尔命令,其参数告诉 Raspberry Pi 如何拍摄照片以及将其放置在何处,然后 JMP 关闭连接并从网络上的位置显示图片。
看https://community.jmp.com/t5/Uncharted/Can-JSL-talk-to-Linux/ba-p/33689使用非 Raspberry Linux 机器的类似想法。 问题之一是通过创建公钥/私钥对来避免密码提示;我使用 puttygen(PuTTY 套件)来制作我的公钥/私钥对(未显示),并且通过在 putty 中保存一个名为的配置文件,使我的 JSL 变得更加简单相机;配置文件具有连接信息:
PuTTY dialog high lighting load/save sessions and AuthPuTTY dialog high lighting load/save sessions and AuthPuTTY dialog high lighting load/save sessions and AuthPuTTY dialog high lighting load/save sessions and AuthPuTTY 对话框高照明负载/保存会话和身份验证
PuTTY dialog showing private key in AuthPuTTY dialog showing private key in AuthPuTTY dialog showing private key in AuthPuTTY dialog showing private key in AuthPuTTY 对话框在 Auth 中显示私钥
Login using the public/private keyLogin using the public/private keyLogin using the public/private keyLogin using the public/private key使用公钥/私钥登录
现在该配置文件也可用于普林克作为相机。 因此,这里有一些用于登录的 JSL:
rp = RunProgram(
executable( "plink" ), // plink is part of the PuTTY toolset, a bit like SSH
options( "camerapi" ), // this is a saved session in PuTTY
ReadFunction(
Function( {this},
While( this << canread,
Write( this << read ); // stream output to JMP log window
Wait( .01 );
)
)
)
);此 JSL 离开RP持有一个在后台运行的 RunProgram 对象,等待 Raspberry 上的 shell 程序产生一些输出...它将其复制到 JMP 日志窗口:
The first yellow is a message from JMP; the last yellow is a prompt from the RaspberryThe first yellow is a message from JMP; the last yellow is a prompt from the RaspberryThe first yellow is a message from JMP; the last yellow is a prompt from the RaspberryThe first yellow is a message from JMP; the last yellow is a prompt from the Raspberry第一个黄色是来自 JMP 的消息;最后一个黄色是树莓派的提示
白色日志窗口包含与黑色外壳窗口相同的登录结果。 ESC 的东西对输出进行颜色编码,所以我得到青色提示。 RunProgram 对象仍在等待将一些命令传递给 Raspberry Pi。 构造一个命令并发送它:
// filename builds a path known to the linux (raspberry pi) computer; it is
// actually a nfs mount from yet another computer. This filename is where the
// picture will be stored. The windows computer running JMP can access the
// NFS mount via the H: drive, which is being supplied through VirtualBox.
filename = "capture/picNoOptions.jpg";
// raspistill is a raspberry pi-specific linux command to take a picture
// using the camera attached to the raspberry pi. Because this is a
// command line interface the command must end with a newline, as if
// it was typed at the keyboard and ENTER was pressed.
command = "raspistill --timeout 1000 --nopreview --output " ||"/mnt/nfsc/upscale/"|| filename;
rp << Write( command || "\!n" ); // send the raspistill command, via the linux command line
这会在日志窗口中产生更多输出:
The command is in yellow, it runs silently, and prompts for another commandThe command is in yellow, it runs silently, and prompts for another commandThe command is in yellow, it runs silently, and prompts for another commandThe command is in yellow, it runs silently, and prompts for another command该命令呈黄色,静默运行,并提示输入另一个命令
此时可以关闭RunProgram连接;向正在运行的 shell 发送 exit 命令是彻底断开连接的最佳方法:
// for RunProgram to end cleanly, the shell it is running must terminate
rp << Write( "exit\!n" ); // end the Linux shell session
同样,有一些日志窗口输出:
The shell is now closedThe shell is now closedThe shell is now closedThe shell is now closed外壳现已关闭
JSL 的其余部分将根据需要等待,然后进行清理:
// every thing above happened very quickly, but the raspistill and exit
// commands have not finished yet. ask the rp object, over and over, if
// the pipe of data from the shell back to JSL has been closed yet. Until
// the ReadEOF happens, RunProgram will not terminate nicely.
While( !(rp << isReadEOF), write("."); Wait( .25 ) ); // wait patiently while shell output goes to log
If( !(rp << canread) & !(rp << canwrite) & rp << isReadEOF,
rp = 0; // this will really make RunProgram go away
Write( "\!nDone" );
,
// possibly need to restart JMP, and possibly need to restart raspberry
Write( "\!nFailed to release rp" )
);因为我已经在等待输出,所以它只是说“完成”。 您可能需要在之前添加 wait(0.1) if( 可以读/可以写/isReadEOF )每次都测试完成。
现在从网络上抓取图片并展示一下:
img=newimage("h:/"||filename);
img<<SCALE></SCALE>
1/8 actual size, attic work space1/8 actual size, attic work space1/8 actual size, attic work space1/8 actual size, attic work space1/8实际尺寸,阁楼工作空间
该相机非常基本,最大分辨率为 2592x1944(我认为这是原始的 5M 相机,还有 8M 版本),但确实允许控制曝光时间和模拟增益,并且可以从传感器检索原始像素。