Raspberry, bottom, and camera, top.Raspberry, bottom, and camera, top.Raspberry, bottom, and camera, top.Raspberry, bottom, and camera, top.Framboise, en bas et caméra, en haut. https://en.wikipedia.org/wiki/Raspberry_Pi est un ordinateur à 35 $ ; une caméra ajoute 25 $ supplémentaires. Ajoutez une alimentation électrique et une connexion Internet et c’est accessible à distance. Comment JMP peut-il y accéder ?
Dans cet exemple, plink (partie de la Mastic suite) et RunProgram (qui fait partie de JMP), connectez JMP à l'interface de ligne de commande Linux du Raspberry Pi. JMP envoie le raspistill commande, avec des paramètres qui indiquent au Raspberry Pi comment prendre la photo et où la mettre, puis JMP ferme la connexion et affiche l'image depuis son emplacement sur le réseau.
Voir https://community.jmp.com/t5/Uncharted/Can-JSL-talk-to-Linux/ba-p/33689 pour des idées similaires utilisant des machines non-Raspberry Linux. L'un des problèmes consiste à éviter les demandes de mot de passe en créant une paire de clés publique/privée ; J'ai utilisé puttygen (suite PuTTY) pour créer ma paire de clés publique/privée (non illustrée), et j'ai rendu mon JSL beaucoup plus simple en enregistrant un profil dans Putty nommé caméra ; le profil contient les informations de connexion :
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 AuthBoîte de dialogue PuTTY, sessions de charge/sauvegarde d'éclairage élevé et authentification
PuTTY dialog showing private key in AuthPuTTY dialog showing private key in AuthPuTTY dialog showing private key in AuthPuTTY dialog showing private key in AuthBoîte de dialogue PuTTY affichant la clé privée dans Auth
Login using the public/private keyLogin using the public/private keyLogin using the public/private keyLogin using the public/private keyConnectez-vous en utilisant la clé publique/privée
Désormais, le profil est également disponible pour plink comme caméra . Voici donc du JSL pour vous connecter :
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 );
)
)
)
);Ce JSL part rp tenant un objet RunProgram qui s'exécute en arrière-plan, attendant que le programme shell du Raspberry produise une sortie... qu'il copie dans la fenêtre de journal 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 RaspberryLe premier jaune est un message de JMP ; le dernier jaune est une invite du Raspberry
La fenêtre de journal blanche contient les mêmes résultats de connexion que la fenêtre shell noire. Le truc ESC code couleur la sortie afin que je reçoive une invite cyan. Et l'objet RunProgram attend toujours de transmettre quelques commandes au Raspberry Pi. Construisez une commande et envoyez-la :
// 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
Cela produit davantage de résultats dans la fenêtre de journal :
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 commandLa commande est en jaune, elle s'exécute silencieusement et demande une autre commande
À ce stade, la connexion RunProgram peut être fermée ; envoyer la commande exit au shell en cours d'exécution est le meilleur moyen de se déconnecter proprement :
// for RunProgram to end cleanly, the shell it is running must terminate
rp << Write( "exit\!n" ); // end the Linux shell session
Encore une fois, il y a un peu de sortie de la fenêtre de journal :
The shell is now closedThe shell is now closedThe shell is now closedThe shell is now closedLa coque est maintenant fermée
Le reste du JSL attendra, si nécessaire, puis nettoiera :
// 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" )
);Parce que j'ai déjà attendu la sortie, il dit simplement "Terminé". Vous devrez peut-être ajouter wait(0.1) avant le si ( canread/canwrite/isReadEOF ) test pour être terminé à chaque fois.
Maintenant, récupérez l'image du réseau et montrez-la :
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 taille réelle, espace de travail grenier
La caméra est assez basique, la résolution maximale est de 2592x1944 (je pense que c'est la caméra 5M d'origine, il existe également une version 8M) mais permet de contrôler le temps d'exposition et le gain analogique et peut récupérer les pixels bruts du capteur.