Cov txheej txheem:

Pib Nrog Raspberry Pi Lub Koob Yees Duab: 6 Kauj Ruam
Pib Nrog Raspberry Pi Lub Koob Yees Duab: 6 Kauj Ruam

Video: Pib Nrog Raspberry Pi Lub Koob Yees Duab: 6 Kauj Ruam

Video: Pib Nrog Raspberry Pi Lub Koob Yees Duab: 6 Kauj Ruam
Video: Saib Mis paub Poj niam (hluas nkauj) tus yam ntxwv lub siab 2024, Kaum ib hlis
Anonim
Pib Nrog Raspberry Pi Lub Koob Yees Duab
Pib Nrog Raspberry Pi Lub Koob Yees Duab

Qhia me ntsis

Raspberry Pi Lub Koob Yees Duab v2.1 tau nruab nrog 8 megapixel Sony IMX219 duab sensor thiab txhim kho txhim kho kom pom tseeb. Nws yog sib xws nrog txhua tus qauv Raspberry Pi. Nws kuj muaj peev xwm ntawm 3280 x 2464 pixel cov duab zoo li qub, thiab tseem txhawb nqa 1080p30, 720p60 thiab 640x480p90 video.

Yam Koj Yuav Kawm

  • Hauv qhov kev qhia no, koj yuav kawm paub siv thiab txuas lub koob yees duab rau Raspberry Pi 4 pawg thawj coj.
  • Yuav ua li cas tswj lub koob yees duab siv Python Yuav siv raspivid, raspistill thiab raspiyuv cov khoom siv li cas
  • Yuav siv start_preview () thiab stop_preview () los tso saib cov duab los ntawm lub koob yees duab
  • Yuav ua li cas thaij duab siv kev ntes () hais kom ua
  • Yuav ua li cas kaw cov vis dis aus siv start_recording () thiab stop_recording ()
  • Yuav ua li cas saib cov vis dis aus ntawm omxplayer Yuav ua li cas hloov qhov ci ci, sib piv thiab daws teeb meem hauv cov duab
  • Yuav ua li cas siv qhov pom kev zoo rau video

Khoom siv

  • Raspberry Pi 4 Qauv B.
  • Raspberry Pi Lub Koob Yees Duab Board v2.1
  • Ib daim npav micro-SD nrog preinstalled Raspbian operating system
  • Lub hwj chim sib xws - koj tseem tuaj yeem siv 5V 2.5A USB khoom

Kauj ruam 1: Kev npaj

Kev npaj
Kev npaj
Kev npaj
Kev npaj

Nco ntsoov tias koj muaj qhov hloov tshiab kawg ntawm Raspbian operating system Koj tuaj yeem rub tawm qhov hloov tshiab kawg los ntawm tus nom Raspberry lub vev xaib. Kuv twb tau tshaj tawm phau ntawv qhia pib sai sai no. Txheeb nws tawm.

Tom qab teeb tsa OS, peb yuav tshuaj xyuas seb cov tsav tsheb tshiab tau teeb tsa nrog cov lus txib hauv qab no.

sudo apt-tau hloov tshiab

Cov lus txib no hloov kho cov npe ntawm cov pob khoom muaj thiab lawv cov qauv.

sudo apt-tau hloov tshiab

Tam sim no qhib lub koob yees duab sib tham los ntawm kev qhib Raspberry Pi cov ntawv teeb tsa:

  1. Mus rau Preferences menu -> Raspberry Pi Configuration
  2. Pab kom lub koob yees duab los ntawm Interfaces xaiv thiab nyem OK.
  3. Tom qab qhib lub koob yees duab, lub kaw lus yuav hais kom koj rov pib dua nws. Reboot lub system.

Kauj Ruam 2: Yuav Ua Li Cas Txuas Lub Koob Yees Duab rau Raspberry Pi

Yuav Ua Li Cas Txuas Lub Koob Yees Duab rau Raspberry Pi
Yuav Ua Li Cas Txuas Lub Koob Yees Duab rau Raspberry Pi

Lub koob yees duab module txuas nrog Raspberry PI pawg thawj coj saib tshwj xeeb CSI (Camera Serial Interface) txuas, uas muaj qhov nrawm txaus rau xa cov vis dis aus cov ntaub ntawv mus txog 1080p ntawm 30 ntas ib ob lossis 720p ntawm 60 fps.

CSI interface, tsis zoo li lub koob yees duab USB, tso cai rau koj kom tsis txhob nqa lub Raspberry processor thiab siv lub koob yees duab kom zoo li sai tau.

Txuas lub koob yees duab mus rau Raspberry Pi board

Txhawm rau ua qhov no, koj xav tau:

  1. Tua lub Raspberry Pi.
  2. Ua tib zoo nrhiav lub koob yees duab chaw nres nkoj thiab nqa cov tab
  3. Ua tib zoo ntxig cov kab hluav taws xob los ntawm lub koob yees duab rau hauv qhov txuas thiab xauv cov tab.

Tam sim no txoj hlua yuav tsum tau txuas rau hauv CSI txuas thiab koj tuaj yeem tig rau Raspberry Pi.

Kauj Ruam 3: Siv Duab Siv Siv Raspbian Terminal

Txog kev tswj hwm yooj yim nrog lub koob yees duab, muaj 3 kab hais kom ua cov khoom siv uas tau teeb tsa ua ntej ntawm lub kaw lus:

  1. raspivid - kev siv yees duab ntes
  2. raspistill - cov duab siv hluav taws xob
  3. raspiyuv yog qhov muaj txiaj ntsig zoo ib yam li raspistill, tab sis hloov cov ntaub ntawv jpg, vim li ntawd nws tsim cov ntaub ntawv nyoos (tsis tau nrawm, tsis ua tiav).

Ib daim ntawv teev tag nrho cov kev txwv rau txhua qhov kev siv hluav taws xob tuaj yeem tau txais yog tias koj ua haujlwm tsis muaj qhov ntsuas

raspistill

los yog ua tiav qhov txiaj ntsig nrog --help parameter:

raspistill -pab

Cov hauv qab no yog piv txwv ntawm kev siv hluav taws xob:

raspistill -t 2000 -o image-j.webp

Yees duab nrog ncua sijhawm 2 vib nas this, daws teeb meem ntawm 640 × 480 nrog cov ntaub ntawv tso tawm thaum lub sijhawm ua haujlwm ntawm cov khoom siv hluav taws xob (-v) thiab txuag rau duab.jpg.

raspivid -t 10000 -o video.h264

Sau ib daim vis dis aus ntev 10 vib nas this thiab txuag rau video.h264.

Kauj Ruam 4: Siv Duab Siv Python Library - PiCamera

Ntxiv nrog rau cov qauv siv hluav taws xob, lub koob yees duab tuaj yeem siv los ntawm cov txheej txheem software. Piv txwv li, thaum tsim cov txheej txheem kev nyab xeeb, thaum nws tsim nyog qhib kev kaw, thaum muaj xwm txheej tshwm sim lossis raws li lub sijhawm teem tseg.

Txhawm rau ua haujlwm nrog lub koob yees duab hauv Python, koj yuav xav tau PiCamera lub tsev qiv ntawv, uas tau teeb tsa ua ntej ntawm lub kaw lus. Yog tias qee qhov laj thawj nws tsis nyob ntawd, tom qab ntawd koj tuaj yeem teeb tsa lub tsev qiv ntawv nrog cov lus txib hauv qab no:

sudo apt-tau nruab python3-picamera

Cov duab kos nrog lub npe picamera.py tsis tuaj yeem siv - qhov no yuav ua rau nws tsis tuaj yeem siv PiCamera lub tsev qiv ntawv hauv Python.

Thaum lub tsev qiv ntawv raug teeb tsa, nws yuav tsum tau nkag rau hauv daim duab:

ntshuam picamera

Cov cai hauv qab no ua rau lub koob yees duab pom ua ntej rau 10 vib nas this

ntshuam picamera

los ntawm lub sijhawm ntshuam lub koob yees duab pw = picamera. PiCamera () lub koob yees duab.start_preview () tsaug zog (10) camera.stop_preview ()

Cov cai hauv qab no ua rau lub koob yees duab pom ua ntej rau 5 vib nas this, tom qab ntawd thaij duab thiab khaws nws li "duab" ntawm koj lub desktop.

ntshuam picamera

los ntawm lub sijhawm ntshuam pw lub koob yees duab = picamera. PiCamera () camera.start_preview () pw (5) camera.capture ('/home/pi/Desktop/image.jpg') camera.stop_preview ()

Kauj Ruam 5: Kaw Video Siv Python Library - PiCamera

Txhawm rau tua cov vis dis aus, peb yuav siv start_recording () thiab stop_recording () cov lus txib.

ntshuam picamera

los ntawm lub sijhawm ntshuam pw tsaug zog camera.start_preview () camera.start_recording ('/home/pi/video.h264') pw (10) camera.stop_recording () camera.stop_preview ()

Tom qab 10 vib nas this, cov vis dis aus yuav xaus thiab yuav raug khaws cia rau hauv video.h264 cov ntaub ntawv hauv koj tus neeg siv lub hauv paus nplaub tshev. Txhawm rau saib cov vis dis aus, siv qhov program omxplayer.

omxplayer video.h264

Kauj Ruam 6: Cov teebmeem

Lub tsev qiv ntawv Picamera rau Python tso cai rau koj siv ntau qhov chaw thiab lim dej uas tuaj yeem siv rau ob qho kev saib ua ntej thiab yees duab nws tus kheej.

Ntxiv cov ntawv

Koj tuaj yeem ntxiv cov ntawv sau rau hauv daim duab uas siv cov lus txib annotate_text. Koj kuj tseem tuaj yeem hloov cov ntawv me me nrog cov ntawv sau hauv qab. Saib qhov piv txwv hauv qab no:

ntshuam picamera

los ntawm lub sijhawm ntshuam pw lub koob yees duab = picamera. PiCamera () camera.start_preview () camera.annotate_text = "Nyob zoo ntiaj teb !!!" camera.annotate_text_size = 60 pw (10) camera.stop_preview ()

Hloov cov duab daws teeb meem

Los ntawm lub neej ntawd, ib daim duab raug coj los ntawm kev daws teeb meem uas tau teeb tsa ntawm koj lub monitor, tab sis koj tuaj yeem hloov nws siv lub koob yees duab.resolution () hais kom ua.

camera.resolution = (2592, 1944)

Kho qhov ci ci lossis qhov sib txawv ntawm daim duab

Koj tuaj yeem kho qhov ci ntawm daim duab los ntawm kev teeb tsa nws ntawm 0 txog 100. Los ntawm lub neej ntawd, 50 tau siv. Yog tias koj xav teeb qhov ci ci, piv txwv li, rau 70, qhia meej cov cai hauv qab no tom qab pib ua ntej:

camera.brightness = 70

Txhawm rau teeb tsa qhov sib piv, siv lub koob yees duab.contrast hais kom ua.

Teeb pom kev zoo

Koj tuaj yeem siv lub koob yees duab.image_effect txhawm rau txhawm rau ntau qhov sib txawv ntawm cov teebmeem pom: tsis zoo, hnub ci, kos duab, kos duab, kos duab, pleev xim, pleev xim, daug, gpen, pastel, xim dej, zaj duab xis, plooj, saturation, xim ntxhua khaub ncaws, daim ntawv lo, xim xim, xim sib npaug, tas luav, deinterlace1, deinterlace2, tsis muaj.

Nrog kev pab los ntawm cov haujlwm hauv qab no koj tuaj yeem pom txhua qhov lim dej muaj. Txoj cai yuav hloov pauv qhov pom kev txhua txhua 5 vib nas this:

ntshuam picamera los ntawm lub sijhawm ntshuam pw

camera = picamera. PiCamera () camera.start_preview () for effect in camera. IMAGE_EFFECTS: camera.image_effect = effect camera.annotate_text = "Effect: % s" % effect sleep (5) camera.stop_preview ()

Koj tuaj yeem pom cov npe ua tiav thiab cov yam ntxwv ntawm lub tsev qiv ntawv picamera ntawm lub vev xaib raug cai.

Kuv vam tias koj pom phau ntawv qhia no muaj txiaj ntsig thiab ua tsaug rau kev nyeem. Yog tias koj muaj lus nug lossis tswv yim? Tawm lus tawm hauv qab no. Nyob twj ywm!

Pom zoo: