LoginSignup
0
0

More than 1 year has passed since last update.

MacからRaspberryPiのGUIを表示させる方法

Posted at

きっかけ

OpenCVによる顔認識をRaspberryPi上で動作させたいと思い、プログラムを書いていました。
実際にプログラムを動作させる段階になり、顔をどのように認識しているかチェックしたかったのですが、MacからSSHして見ているCUI上だと何も出来ず...
RaspberryPiのGUIで確認したいのだが、一々キーボード・マウス・HDMIをRaspberryPi上に繋げるのも面倒...
何かいい方法が無いかと探してみました

やりたい事

  • MacからRaspberryPiにサッとリモート接続して、GUIを表示させる

やった事

  • RaspberryPiにVNCサーバのインストール
  • MacからVNCサーバと化したRaspberryPiへのリモートアクセス

VNC(Virtual Network Computing)

VNCとは、ネットワークを通じて別のコンピュータに接続し、そのデスクトップ画面を呼び出して操作することができるリモートデスクトップソフトの一つ。また、オリジナルのVNCを元に開発された派生ソフトウェア群の総称。様々な環境に移植され、相互に接続可能なため、異なるOSで操作するコンピュータの画面を呼び出して操作することができる。
参考: VNC 【Virtual Network Computing】 IT用語辞典

  • VNCはリモートデスクトップソフトの名称
  • VNCサーバ:リモート接続受け入れが出来ているサーバ
  • VNCクライアント:VNCサーバに対してリモート接続する事が可能なクライアント

TightVNC

RaspberryPiのVNCサーバとして、TightVNCを使用する

What is TightVNC?
TightVNC is a free remote desktop application. With TightVNC, you can see the desktop of a remote machine and control it with your local mouse and keyboard, just like you would do it sitting in the front of that computer.
参考:TightVNC Software

リモート接続までの道のり

流れ

  1. RaspberryPiにVNCサーバのインストール
  2. tightvncserverの起動
  3. MacからRaspberryPiへリモートアクセス

RaspberryPiにVNCサーバのインストール

$ sudo apt-get update
$ sudo apt-get install tightvncserver

tightvncserverの起動

# 起動
$ tightvncserver

# Passwordの初期設定
You will require a password to access your desktops.

Password:
Warning: password truncated to the length of 8.
Verify:

# ViewOnlyのパスワードを設定するか
Would you like to enter a view-only password (y/n)? n

New 'X' desktop is raspberrypi:1

Creating default startup script /home/pi/.vnc/xstartup
Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

MacからRaspberryPiへリモートアクセス

MacのFinderで、移動 -> サーバーへ移動 を行う。
スクリーンショット 2021-08-22 14.00.30.png

Host名の変更を行っていない場合は、vnc://raspberrypi.local:5901とすれば接続が出来る。
VNCサーバのPortは何も設定していない場合、5901になるらしい。
スクリーンショット 2021-08-22 14.01.29.png

GUIが表示されれば完了
スクリーンショット 2021-08-22 14.03.37.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0