<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                https://picamera.readthedocs.io/en/release-1.13/index.html ## 將攝像頭連接到樹莓派上 關閉樹莓派后,將相機模塊連接到樹莓派的“**CAMERA**”接口。 輕輕向上拉“CAMERA”接口的塑料夾邊緣,然后推入攝像頭色帶,最后將塑料夾推回原位。 ## 在raspi-config中使能攝像頭 啟動樹莓派,打開終端,在樹莓派終端中輸入下面命令,以打開Raspberry Pi配置工具。 ``` sudo raspi-config ``` 移動到“**Interfacing Options**”,按下回車鍵。然后選擇“**Camera**”,按下回車鍵。 <div align="center"><img src="images/screenshot_1559782375623.png"/></div> 選擇“**Enable**”,然后回車。 <div align="center"><img src="images/screenshot_1559782435569.png"/></div> ## 測試攝像頭是否可用 在終端中輸入命令: ``` raspistill -o test.jpg -t 3000 ``` 延時3秒拍攝一張靜態圖片,并命名為test.jpg ## 相機預覽 新建一個文件 ```python sudo nano camera.py ``` 輸入以下代碼: ```python from picamera import PiCamera from time import sleep camera = PiCamera() #獲取一個PiCamera對象 camera.start_preview() #打開攝像頭進行預覽 sleep(10) #暫停10秒,即預覽10秒 camera.stop_preview() #關閉預覽 ``` 然后“**Ctrl + X**”后,按“**Y**”保存退出。 終端輸入命令,以運行“camera\.py”文件: ```python python camera.py ``` 如果圖像是顛倒的,可以在“camera.start_preview()”前添加以下代碼來旋轉它: ```python camera.rotation = 180 ``` 可以按90,180或270度來旋轉圖像,也可以將其設置0來重置它。 可以通過設置Alpha級別來更改相機預覽的透明度: ```python camera.start_preview(alpha = 200) ``` alpha可以是0到255之間的值。 ## 拍攝圖片 修改代碼 ```python camera.start_preview() sleep(5) camera.capture('/home/pi/Desktop/image.jpg') camera.stop_preview() ``` 運行代碼,相機預覽打開5秒鐘,預覽會立即調整到不同的分辨率,然后拍攝一張靜態圖片。 程序運行結束后,在桌面上出現剛拍攝的圖片,雙擊文件圖標將其打開。 嘗試加入循環以連續拍攝五張照片: ```python camera.start_preview() for i in range(5): sleep(5) camera.capture('/home/pi/Desktop/image%s.jpg' % i) camera.stop_preview() ``` ## 錄制視頻 修改代碼,將`capture()`替換成`start_recording()`和`stop_recording()`。 ```python camera.start_preview() camera.start_recording('/home/pi/video.h264') sleep(10) camera.stop_recording() camera.stop_preview() ``` 運行代碼,將會錄制10秒的視頻。 輸入下面命令,然后按回車播放視頻。 > 函數`start_recording()`支持的視頻格式如下: > * 'h264' - Write an H.264 video stream > * 'mjpeg' - Write an M-JPEG video stream > * 'yuv' - Write the raw video data to a file in YUV420 format > * 'rgb' - Write the raw video data to a file in 24-bit RGB format > * 'rgba' - Write the raw video data to a file in 32-bit RGBA format > * 'bgr' - Write the raw video data to a file in 24-bit BGR format > * 'bgra' - Write the raw video data to a file in 32-bit BGRA format ```python omxplayer video.h264 ``` 由于omxplayer幀速率快,所以播放時比實際的視頻更快。 PiCamera庫學習地址:https://picamera.readthedocs.io/en/release-1.13/api_array.html
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看