# 9.1.1.3. Raspberry Pi Camera v2 樹莓派攝影機

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LmDE6jZng-dSz5cRZRw%2F-LmDEHBonsgNl_YIO73t%2FPi-Camera-front.jpg?alt=media&#x26;token=855c68aa-e131-46f4-8eb3-1923c14da082" alt=""></div>

* **Overview**

請參閱 [**Raspberry Pi Camera V2 樹莓派攝影機**](http://emanual.robotis.com/docs/en/platform/turtlebot3/appendix_raspi_cam/#overview)的詳細說明

* **規格**

請參閱 [**Raspberry Pi Camera V2 樹莓派攝影機**](http://emanual.robotis.com/docs/en/platform/turtlebot3/appendix_raspi_cam/#overview)的詳細說明

* 安裝

{% hint style="danger" %}
警示：Raspberry pi 樹莓派必須先安裝，之後再來設定 Raspberry Pi Camera v2 攝影機。 請參考 [**Raspberry Pi 3 安裝程序**](http://emanual.robotis.com/docs/en/platform/turtlebot3/raspberry_pi_3_setup/)
{% endhint %}

**\[Raspberry pi 樹莓派]** 設定攝影機硬體

```
$ sudo raspi-config
```

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LmDE6jZng-dSz5cRZRw%2F-LmDKtE7I19icXYf2Xix%2Fpi-cam-hardware-setting-1.png?alt=media&#x26;token=0f85b286-3ec2-442f-b188-c5046ffda558" alt=""></div>

選擇 **3 Interfacing Options**

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LmDE6jZng-dSz5cRZRw%2F-LmDL1wvcDISs0BxVZ83%2Fpi-cam-hardware-setting-2.png?alt=media&#x26;token=04d3db54-52e7-4e50-8457-7d065e2ee8cf" alt=""></div>

選擇 **P1 Camera**

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LmDE6jZng-dSz5cRZRw%2F-LmDLDOJlUmiyAVc-O2C%2Fpi-cam-hardware-setting-3.png?alt=media&#x26;token=19b5e867-4420-419c-bdfa-a03d3104cc50" alt=""></div>

啟用 camera interface

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LmDE6jZng-dSz5cRZRw%2F-LmDLM79jsIk1RN8-YyL%2Fpi-cam-hardware-setting-4.png?alt=media&#x26;token=b8af5654-876f-4bf0-b2a8-ecea5beef821" alt=""></div>

<div align="left"><img src="https://3058168660-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LkXc5k_SFaP9gK2gsU8%2F-LmDE6jZng-dSz5cRZRw%2F-LmDLRNEi6CS-t_iJxob%2Fpi-cam-hardware-setting-5.png?alt=media&#x26;token=5a5e5640-890d-41d0-93c7-89572e8188ae" alt=""></div>

重新啟動 Raspberry Pi 後，要測試系統是否已安裝並正常工作，請輸入以下指令：

```
$ raspistill -v -o test.jpg
```

螢幕上應顯示攝影機的五秒預覽，然後拍照，保存到 test.jpg 檔。

以下指令將在你的 ROS 系統上安裝相關的 Raspberry Pi Camera 攝影機套件。

```
$ sudo apt-get install ros-kinetic-compressed-image-transport ros-kinetic-camera-info-manager ros-kinetic-ar-track-alvar ros-kinetic-ar-track-alvar-msgs ros-kinetic-image-proc
```

```
$ cd ~/catkin_ws/src
$ git clone https://github.com/UbiquityRobotics/raspicam_node.git
$ git clone https://github.com/ROBOTIS-GIT/open_manipulator_perceptions.git
$ cd ~/catkin_ws && catkin_make
```

* **執行**

{% hint style="danger" %}
警示：在 Remote PC 中運行 rqt\_image\_view 之前，請檢查 Raspberry Pi和 Remote PC 是否已連接。請參考以下連接。

* [Raspberry Pi 3 Setup ](http://emanual.robotis.com/docs/en/platform/turtlebot3/raspberry_pi_3_setup/#5-network-configuration)
* [Remote PC Setup](http://emanual.robotis.com/docs/en/platform/turtlebot3/pc_setup/#network-configuration)
{% endhint %}

**\[Remote PC 端]** 執行以下指令

```
$ roscore
$ rqt_image_view
```

**\[Raspberry Pi 樹莓派]** 執行以下指令

```
$ roslaunch roslaunch open_manipulator_camera raspicam.launch
```

* **參考資源**
  * [Raspberry Pi Camera ](https://www.raspberrypi.org/documentation/hardware/camera/README.md)
  * [Getting Started ](https://projects.raspberrypi.org/en/projects/getting-started-with-picamera)
  * [Pi Camera ROS package](https://github.com/UbiquityRobotics/raspicam_node)
