Raspberry, bottom, and camera, top.ラズベリー(下)とカメラ(上)。 https://en.wikipedia.org/wiki/Raspberry_Piは 35 ドルのコンピューターです。カメラを追加するとさらに 25 ドル追加されます。電源とインターネット接続を追加すると、リモートからアクセスできます。 JMP はどのようにしてそれにアクセスできますか?
この例では、 plink ( PuTTYスイートの一部) と RunProgram (JMP の一部) により、JMP が Raspberry Pi の Linux コマンド ライン インターフェイスに接続されます。 JMP は、Raspberry Pi に写真の撮影方法と写真の保存場所を指示するパラメーターを含むraspistillコマンドを送信します。その後、JMP は接続を閉じて、ネットワーク上のその場所から写真を表示します。
Raspberry Linux 以外のマシンを使用した同様のアイデアについては 、https://community.jmp.com/t5/Uncharted/Can-JSL-talk-to-Linux/ba-p/33689を参照してください。問題の 1 つは、公開キーと秘密キーのペアを作成してパスワード プロンプトを回避することです。 puttygen (PuTTY スイート) を使用して公開鍵と秘密鍵のペア (図示せず) を作成し、カメラという名前のプロファイルを putty に保存することで JSL をはるかに単純にしました。プロファイルには接続情報が含まれています。
PuTTY dialog high lighting load/save sessions and AuthPuTTY ダイアログのハイライト ロード/保存セッションと認証
PuTTY dialog showing private key in Auth認証の秘密キーを表示する PuTTY ダイアログ
Login using the public/private key公開キー/秘密キーを使用してログインする
プロファイルをカメラとしてplink することもできるようになりました。したがって、ログインするための 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 上のシェル プログラムが出力を生成するのを待ちます...出力は JMP ログ ウィンドウにコピーされます。
The 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 commandコマンドは黄色で表示され、サイレントに実行され、別のコマンドの入力を求められます。
この時点で、RunProgram 接続を閉じることができます。正常に切断するには、実行中のシェルに 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 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" )
);すでに出力を待っているので、「完了」と表示されるだけです。毎回 Done を取得するには、 if( canread/canwrite/isReadEOF )テストの前に wait(0.1) を追加する必要がある場合があります。
次に、ネットワークから画像を取得して表示します。
img=newimage("h:/"||filename);
img<<SCALE></SCALE><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1/8 actual size, attic work space" style="width: 343px;"><span class="lia-inline-image-display-wrapper" image-alt="1/8 actual size, attic work space" style="width: 343px;"><img src="https://us.v-cdn.net/6038925/uploads/images/19359i5CDA44EAE94B717C/AtticWorkShop.PNG" role="button" title="AtticWorkShop.PNG" alt="1/8 actual size, attic work space" /><span class="lia-inline-image-caption" onclick="event.preventDefault();">1/8 actual size, attic work space</span></span><SPAN class="lia-inline-image-caption" onclick="event.preventDefault();">1/8実物大、屋根裏作業スペース</SPAN></SPAN>
The camera is pretty basic, maximum resolution is 2592x1944 (I think this is the original 5M camera, there is also an 8M version) but does allow controlling exposure time and analog gain and can retrieve raw pixels from the sensor.