Cov txheej txheem:

Ua Koj Tus Kheej Lub Koob Yees Duab: 8 Kauj Ruam
Ua Koj Tus Kheej Lub Koob Yees Duab: 8 Kauj Ruam

Video: Ua Koj Tus Kheej Lub Koob Yees Duab: 8 Kauj Ruam

Video: Ua Koj Tus Kheej Lub Koob Yees Duab: 8 Kauj Ruam
Video: Hi So - Koj haib 2 (Official MV nkauj tawm tshiab 2019-2020) 2024, Hlis ntuj nqeg
Anonim
Image
Image
Ua Koj Tus Kheej Lub Koob Yees Duab
Ua Koj Tus Kheej Lub Koob Yees Duab

Cov lus qhia no piav qhia yuav ua li cas thiaj ua lub koob yees duab monochrome siv Omnivision OV7670 duab sensor, Arduino microcontroller, ob peb lub xov hlau txuas, thiab Ua 3 software.

Kev sim software kom tau txais cov duab xim kuj tau nthuav tawm.

Nias tus yuam sij "c" txhawm rau ntes 640*480 pixel duab … nias tus "s" kom txuag tau cov duab rau ua ntaub ntawv. Cov duab ua tiav tau suav ua ntu zus yog tias koj xav tsim cov yeeb yaj kiab luv-lapse.

Lub koob yees duab tsis nrawm (txhua qhov kev tshuaj ntsuam siv 6.4 vib nas this) thiab tsuas yog tsim nyog siv rau teeb pom kev zoo.

Tus nqi, tsis suav nrog koj Arduino thiab PC, tsawg dua ib khob kas fes.

Duab

Cov khoom tivthaiv, tsis muaj cov hlua txuas, tau qhia hauv daim duab qhib.

Daim duab thib ob yog lub vijtsam txhaj tshuaj uas qhia txog Arduino lub koob yees duab software thiab Txheej Txheem 3 thav duab-tuav. Cov ntawv qhia pom yuav ua li cas lub koob yees duab txuas nrog.

Cov vis dis aus qhia lub koob yees duab hauv kev nqis tes ua. Thaum tus "c" ntes tus yuam sij tau nyem me ntsis nyem ua raws los ntawm kev ua haujlwm tawg raws li cov duab tau luam tawm. Cov duab cia li tshwm nyob rau hauv lub qhov rai zaub thaum qhov kev tshuaj ntsuam tiav. Cov duab tom qab pom pom tshwm rau hauv Cov Txheej Txheem Ua Haujlwm tom qab txhua qhov nias ntawm "s" tus yuam sij. Cov vis dis aus xaus los ntawm kev caij tsheb nrawm los ntawm txhua ntawm peb daim duab khaws tseg.

Kauj Ruam 1: Daim duab Circuit Court

Daim duab Circuit Court
Daim duab Circuit Court
Daim duab Circuit Court
Daim duab Circuit Court
Daim duab Circuit Court
Daim duab Circuit Court

Daim duab qhia chaw, rau txhua lub qauv ntawm lub koob yees duab no, tau qhia hauv daim duab 1.

Cov duab 2, 3 qhia tias yuav ua li cas cov hlua-cov xov hlau thiab cov khoom sib txuas tau txuas nrog.

Yog tsis muaj cov hlua khi txhuas cov duab dag ntawm lawv ib sab.

Ceeb toom

Ua haujlwm rau koj Arduino ua ntej txuas ib lub xov hlau txuas rau OV7670 lub koob yees duab nti. Qhov no yuav tiv thaiv 5 volt tus pin los ntawm cov haujlwm yav dhau los los ntawm kev rhuav tshem 3v3 volt OV7670 lub koob yees duab nti.

Kauj Ruam 2: Daim Ntawv Teev Npe

Daim Ntawv Teev Npe
Daim Ntawv Teev Npe

Cov hauv qab no tau txais los ntawm

  • 1 tsuas yog OV7670 300KP VGA Lub Koob Yees Duab Module rau arduino DIY KIT
  • 1 tsuas yog lub koob yees duab bracket tiav nrog txiv ntseej thiab ntsia liaj qhov rooj
  • 1 tsuas yog UNO R3 rau arduino MEGA328P 100% thawj ATMEGA16U2 nrog USB Cable

Cov hauv qab no tau txais hauv zos

  • 18 anly Arduino txiv neej-poj niam jumper cables
  • 3 tsuas yog Arduinin poj niam-poj niam jumper cables
  • 1 tsuas yog lub khob cij mini-board
  • 4 tsuas yog 4K7 ohm 1/2 watt resistors
  • 1 tsuas yog seem aluminium sawv ntsug.

Koj tseem yuav xav tau cov ntawv teev cov hauv qab no:

  • https://web.mit.edu/6.111/www/f2016/tools/OV7670_20…
  • https://www.haoyuelectronics.com/Attachment/OV7670%…

Kauj ruam 3: Txoj kev xav

Txoj kev xav
Txoj kev xav

OV7670 lub koob yees duab nti

Lub peev xwm tso tawm los ntawm OV7670 lub koob yees duab nti suav nrog YUV (4: 2: 2) lub teeb liab video thiab 3 lub sijhawm yoj yoj. Lwm cov qauv tsim tawm tuaj yeem ua tau los ntawm kev sau npe sab hauv ntawm lub tsheb npav I2C sib xws.

YUV (4: 2: 2) video teeb liab (daim duab 1) yog qhov sib txuas tas li ntawm cov xim dub (dawb & dawb) pixels cais los ntawm U (xim sib txawv xim) thiab V (xim sib txawv xim) cov lus qhia xim.

Hom ntawv tso tawm no hu ua YUV (4: 2: 2) txij li txhua pab pawg ntawm 4 bytes muaj 2 monochrome bytes thiab thiab 2 xim bytes.

Monochrome

Txhawm rau kom tau txais cov duab monochrome peb yuav tsum ua piv txwv txhua cov ntaub ntawv thib ob byte.

Ib qho Arduino tsuas muaj 2K ntawm kev nkag mus yooj yim nco tab sis txhua tus ncej suav nrog 640*2*480 = 307, 200 cov ntaub ntawv bytes. Tshwj tsis yog peb ntxiv tus thav duab thav duab rau OV7670 txhua cov ntaub ntawv yuav tsum xa mus rau PC kab-los-kab rau kev ua.

Muaj ob txoj hauv kev:

Rau txhua 480 qhov txuas txuas txuas ntxiv, peb tuaj yeem ntes ib kab rau Arduino ntawm kev nrawm ua ntej xa mus rau PC ntawm 1Mbps. Xws li txoj hauv kev yuav pom OV7670 ua haujlwm nrawm tab sis yuav siv sijhawm ntev (zoo li ib feeb).

Txoj hauv kev uas kuv tau ua yog ua kom PCLK qeeb mus rau 8uS thiab xa txhua tus qauv raws li nws los. Txoj hauv kev no tau nrawm dua (6.4 vib nas this).

Kauj Ruam 4: Tsim Cov Lus Cim

Sau Ntawv Tsim
Sau Ntawv Tsim
Sau Ntawv Tsim
Sau Ntawv Tsim
Sau Ntawv Tsim
Sau Ntawv Tsim

Kev sib haum xeeb

OV7670 lub koob yees duab nti yog lub tshuab 3v3 volt. Cov ntaub ntawv qhia pom tias qhov hluav taws xob siab dua 3.5 volts yuav ua rau lub nti puas.

Txhawm rau tiv thaiv koj 5 volt Arduino los ntawm kev rhuav tshem OV7670 lub koob yees duab nti:

  • Lub moos sab nraud (XCLK) teeb liab los ntawm Arduino yuav tsum raug txo kom muaj kev nyab xeeb los ntawm kev faib hluav taws xob.
  • Sab hauv Arduino I2C rub tawm cov neeg tawm tsam rau 5 volts yuav tsum tau xiam thiab hloov nrog cov rub tawm sab nraud sab nraud rau 3v3 volt mov.
  • Program koj Arduino ua ntej txuas ib qho jumper-xov hlau raws li qee tus pin tseem tseem tuaj yeem ua haujlwm raws li qhov tso tawm los ntawm txoj haujlwm ua ntej !!! (Kuv kawm qhov no nyuaj txoj kev… hmoov zoo kuv yuav ob vim lawv pheej yig heev).

Lub moos sab nraud

OV7670 lub koob yees duab nti xav tau lub moos sab nraud hauv qhov ntau zaus 10Mhz txog 24MHz.

Qhov siab tshaj plaws peb tuaj yeem tsim los ntawm 16MHz Arduino yog 8MHz tab sis qhov no zoo li ua haujlwm.

Txuas txuas

Nws siv sijhawm tsawg kawg 10 uS (microseconds) xa 1 cov ntaub ntawv byte hla 1Mbps (lab khoom ib pliag) txuas txuas. Lub sijhawm no yog ua raws li hauv qab no:

  • 8 cov ntaub ntawv me me (8us)
  • 1 pib-ntsis (1uS)
  • 1 nres-ntsis (1uS)

Sab hauv moos

Lub moos pixel sab hauv (PCLK) zaus hauv OV7670 tau teeb tsa los ntawm cov khoom [5: 0] hauv npe CLKRC (saib daim duab 1). [1]

Yog tias peb teev cov khoom [5: 0] = B111111 = 63 thiab siv nws rau cov qauv saum toj no ces:

  • F (moos sab hauv) = F (lub moos nkag)/(Ntsis [5: 0} +1)
  • = 8000000/(63+1)
  • = 125000 Hz los yog
  • = 8 TZS

Txij li peb tsuas yog piv txwv txhua qhov thib ob cov ntaub ntawv byte, PCLK ntu ntawm 8uS cov txiaj ntsig hauv 16uS qauv uas yog lub sijhawm txaus los xa 1 cov ntaub ntawv byte (10uS) tawm hauv 6uS rau kev ua.

Ncej tus nqi

Txhua lub VGA video thav duab suav nrog 784*510 pixels (cov duab duab) ntawm uas 640*480 pixels tau tso tawm. Txij li YUV (4: 2: 2) cov ntawv tso tawm muaj qhov nruab nrab ntawm 2 cov ntaub ntawv bytes ib pixel, txhua tus ncej yuav siv 784*2*510*8 uS = 6.4 vib nas this.

Lub koob yees duab no TSIS YOOJ YIM !!!

Kab rov tav

Cov duab yuav raug txav mus los yog peb hloov HSTART thiab HSTOP qhov tseem ceeb thaum tswj hwm 640 pixel sib txawv.

Thaum txav koj daim duab sab laug, nws tuaj yeem ua rau koj tus HSTOP tus nqi qis dua HSTART tus nqi!

Tsis txhob poob siab … nws yog txhua yam ua nrog cov khoom siv ntau dhau raws li tau piav qhia hauv daim duab 2.

Sau npe

OV7670 muaj 201 yim-ntsis rau npe rau kev tswj hwm yam xws li nce, tshuav dawb, thiab raug.

Ib cov ntaub ntawv byte tsuas yog tso cai rau 256 qhov tseem ceeb hauv thaj tsam [0] txog [255]. Yog tias peb xav tau kev tswj hwm ntau dua ces peb yuav tsum cascade ntau daim ntawv sau npe. Ob bytes muab rau peb 65536 muaj peev xwm… peb bytes muab rau peb 16, 777, 216.

Ace 16 ntsis AEC (Kev Tiv Thaiv Tsis Siv Neeg) sau npe hauv daim duab 3 yog qhov piv txwv thiab tau tsim los ntawm kev sib koom ua ntu ntu ntawm peb cov npe hauv qab no.

  • AECHH [5: 0] = AEC [15:10]
  • AECH [7: 2] = AEC [9: 2]
  • COM1 [1: 0] = AEC [1: 0]

Ceeb toom… qhov chaw nyob rau npe tsis tau koom ua ke!

Cov kev mob tshwm sim

Tus nqi qis qeeb qhia txog tus lej ntawm cov kev mob tshwm sim tsis zoo:

Rau qhov raug qhov raug, OV7670 xav kom ua haujlwm ntawm tus lej ntawm 30 fps (thav duab ib ob). Txij li txhua lub thav duab tau siv sijhawm 6.4 vib nas this lub kaw hluav taws xob tau qhib 180 zaug ntev dua li qhov qub uas txhais tau tias txhua daim duab yuav nthuav tawm dhau tshwj tsis yog tias peb hloov qee qhov kev sau npe.

Txhawm rau tiv thaiv kev kis dhau kuv tau teeb tsa tag nrho AEC (pib tiv thaiv kev tiv thaiv) sau npe cov khoom rau xoom. Txawm li ntawd los yuav tsum tau lim qhov nruab nrab nyob rau sab xub ntiag ntawm lub lens thaum lub teeb pom kev zoo.

Kev nthuav tawm ntev kuj zoo li cuam tshuam rau UV cov ntaub ntawv. Raws li kuv tseem tsis tau pom sau npe ua ke uas tsim cov xim raug … xav txog qhov no kom ua haujlwm tiav.

Nco tseg

[1]

Cov mis qhia hauv cov ntaub ntawv (duab 1) yog qhov raug tab sis qhov ntau tsuas yog qhia me ntsis [4: 0]?

Kauj Ruam 5: Sijhawm Waveforms

Sijhawm Waveforms
Sijhawm Waveforms
Sijhawm Waveforms
Sijhawm Waveforms
Sijhawm Waveforms
Sijhawm Waveforms

Cov ntawv nyob hauv qab kaum sab laug ntawm "VGA Frame Timing" daim duab (daim duab 1) nyeem:

Rau YUV/RGB, tp = 2 x TPCLK

Cov Duab 1, 2, & 3 txheeb xyuas cov ntaub ntawv (s) thiab lees paub tias Omnivision kho txhua 2 cov ntaub ntawv bytes raws li qhov sib npaug ntawm 1 pixel.

Cov oscilloscope waveforms tseem txheeb xyuas tau tias HREF tseem qis qis thaum lub sijhawm sib nrug.

Daim duab 4 lees paub tias XCLK cov zis los ntawm Arduino yog 8MHz. Yog vim li cas peb thiaj pom sinewave, ntau dua li ib lub xwmfab, yog tias txhua qhov sib txawv ntawm qhov sib txawv yog pom tsis tau rau kuv 20MHz kev ntsuas oscilloscope.

Kauj Ruam 6: Ncej Grabber

Ncej Grabber
Ncej Grabber

Cov duab duab nyob hauv OV7670 lub koob yees duab nti suav nrog kab ntawm 656*486 pixels uas daim phiaj ntawm 640*480 pixels tau siv rau daim duab.

HSTART, HSTOP, HREF, thiab VSTRT, VSTOP, VREF sau npe qhov tseem ceeb tau siv los tso tus duab hla lub sensor. Yog tias daim duab tsis nyob ntawm qhov ntsuas kom raug koj yuav pom cov qhab dub hla ib lossis ntau lub npoo raws li tau piav qhia hauv ntu "Tsim Cov Lus Cim".

OV7670 ntsuas txhua kab ntawm daim duab ib lub pixel pib ntawm lub kaum sab laug saum toj kom txog thaum nws mus txog hauv qab txoj cai pixel. Arduino tsuas yog hla cov pixels no mus rau PC ntawm kab ntawv txuas raws li qhia hauv daim duab 1.

Cov thav duab-tuav cov haujlwm yog ntes txhua qhov ntawm 640*480 = 307200 pixels thiab tso tawm cov ntsiab lus hauv qhov "duab" qhov rai

Ua 3 ua tiav qhov no siv plaub kab lus hauv qab no !!

Txoj kab 1:

byte byteBuffer = tshiab byte [maxBytes+1]; // qhov maxBytes = 307200

Cov cai hauv qab hauv nqe lus no tsim:

  • 307201 byte array hu ua "byteBuffer [307201]"
  • Qhov ntxiv byte yog rau kev txiav (linefeed) tus yam ntxwv.

Txoj kab 2:

loj (640, 480);

Cov cai hauv qab hauv nqe lus no tsim:

  • qhov sib txawv hu ua "dav = 640;"
  • qhov sib txawv hu ua "qhov siab = 480";
  • 307200 pixel array hu ua "pixels [307200]"
  • a 640*480 pixel "duab" qhov rai uas cov ntsiab lus ntawm pixels array tau tshwm. Lub qhov rais "duab" no tau rov ua dua tshiab tas li ntawm tus lej ntawm 60 fps.

Txoj kab 3:

byteCount = myPort.readBytesUntil (lf, byteBuffer);

Cov cai hauv qab hauv nqe lus no:

  • buffers cov ntaub ntawv tuaj hauv zos kom txog thaum nws pom "lf" (linefeed) tus cwj pwm.
  • tom qab uas nws dumps thawj 307200 bytes ntawm cov ntaub ntawv hauv zos rau hauv byteBuffer array.
  • Nws tseem txuag tus lej bytes tau txais (307201) rau hauv qhov sib txawv hu ua "byteCount".

Txoj kab 4:

pixels = xim (byteBuffer );

Thaum muab tso rau hauv-rau-tom ntej-lub voj, cov hauv paus hauv kab lus no:

  • luam cov ntsiab lus ntawm "byteBuffer " array rau "pixels " array
  • cov ntsiab lus ntawm qhov tshwm sim hauv daim duab qhov rai.

Qhov tseem ceeb Strokes:

Tus thav duab-tus tuav tau lees paub cov yuam sij hauv qab no:

  • 'C' = ntes cov duab
  • 'S' = txuag cov duab rau ua ntaub ntawv.

Kauj ruam 7: Software

Rub tawm thiab teeb tsa txhua qhov ntawm cov software hauv qab no yog tias tsis tau teeb tsa:

  • "Arduino" los ntawm
  • “Java 8” los ntawm https://java.com/en/download/ [1]
  • "Ua 3" los ntawm

Txhim kho Arduino kos duab:

  • Tshem tag nrho OV7670 jumper xov hlau [2]
  • Txuas USB cable rau koj Arduino
  • Luam cov ntsiab lus ntawm "OV7670_camera_mono_V2.ino" (txuas nrog) rau hauv Arduino "kos duab" thiab txuag.
  • Rub cov duab kos rau koj Arduino.
  • Unplug lub Arduino
  • Tam sim no koj tuaj yeem rov txuas dua OV7670 cov xov hlau txuas tau zoo
  • Txuas tus USB cable dua.

Txhim kho thiab khiav cov txheej txheem txheej txheem

  • Luam cov ntsiab lus ntawm "OV7670_camera_mono_V2.pde" (txuas nrog) rau hauv Txheej Txheem "kos duab" thiab txuag.
  • Nyem rau sab saum toj-sab laug "khiav" khawm … lub qhov rai duab dub yuav tshwm
  • Nyem qhov "dub" duab-qhov rai
  • Nias tus yuam sij "c" txhawm rau ntes cov duab. (kwv yees li 6.4 vib nas this).
  • Nias qhov "s" kom txuag tau cov duab hauv koj daim ntawv ua tiav
  • Rov ua cov kauj ruam 4 & 5
  • Nyem rau qhov “nres” khawm kom tawm qhov program.

Sau ntawv

[1]

Kev ua 3 yuav tsum muaj Java 8

[2]

Qhov no yog "ib zaug nkaus xwb" kev nyab xeeb kom tsis txhob ua rau koj lub OV7670 lub koob yees duab nti.

Txog thaum kos duab "OV7670_camera_mono.ini" tau muab tso rau hauv koj li Arduino lub zog rub tawm sab hauv txuas nrog 5 volts, ntxiv rau qhov muaj peev xwm ua tau tias qee qhov ntawm Arduino cov kab ntawv yuav yog 5 volt outputs … txhua qhov uas ua rau tuag taus 3v3 volt OV7670 lub koob yees duab nti.

Thaum Arduino tau ua haujlwm lawm tsis tas yuav rov ua cov kauj ruam no thiab cov npe sau npe yuav raug hloov pauv yam nyab xeeb.

Kauj Ruam 8: Tau Txais Cov Duab Xim

Tau Txais Cov Duab Xim
Tau Txais Cov Duab Xim
Tau Txais Cov Duab Xim
Tau Txais Cov Duab Xim
Tau Txais Cov Duab Xim
Tau Txais Cov Duab Xim

Cov software hauv qab no yog kev sim dawb huv thiab tau tshaj tawm hauv kev cia siab tias qee cov txheej txheem yuav ua pov thawj muaj txiaj ntsig. Cov xim zoo li hloov pauv… Kuv tseem tsis tau pom qhov chaw tso npe raug. Yog tias koj pom kev daws teeb meem thov tshaj tawm koj cov txiaj ntsig

Yog tias peb xav tau daim duab xim, txhua cov ntaub ntawv bytes yuav tsum raug ntes thiab siv cov qauv hauv qab no.

OV7670 siv cov qauv hauv qab no los hloov RGB (liab, ntsuab, xiav) xim xov xwm rau hauv YUV (4: 2: 2): [1]

  • Y = 0.31*R + 0.59*G + 0.11*B.
  • UA = B - Y
  • V = R - Y
  • Cb = 0.563*(B-Y)
  • Cr = 0.713*(R-Y)

Cov qauv hauv qab no tuaj yeem siv los hloov YUV (4: 2: 2) rov qab rau RGB xim: [2]

  • R = Y + 1.402* (Cr - 128)
  • G = Y -0.344136*(Cb -128) -0.714136*(Cr -128)
  • B = Y + 1.772*(Cb -128)

Cov software txuas nrog tsuas yog kev txuas ntxiv ntawm software monochrome:

  • Kev thov ntes "c" raug xa mus rau Arduino
  • Arduino xa tus lej txawm (monochrome) bytes mus rau PC
  • Lub PC khaws cov bytes no mus rau hauv ib qho array
  • Arduino txuas ntxiv xa cov lej sib txawv (chroma) bytes mus rau PC.
  • Cov bytes no tau txais kev cawmdim rau hauv kab thib ob… peb tam sim no muaj tag nrho cov duab.
  • Cov txheej txheem saum toj no tam sim no siv rau txhua pab pawg ntawm plaub UYVY cov ntaub ntawv bytes.
  • Cov xim pixels uas tau tshwm sim yog tom qab ntawd tso rau hauv "pixels " kab
  • Lub PC tshuaj xyuas qhov "pixels " array thiab cov duab tshwm nyob rau hauv "duab" qhov rai.

Cov Txheej Txheem 3 software qhia luv luv txhua qhov scan thiab cov txiaj ntsig kawg:

  • Daim duab 1 qhia txog U & V chroma cov ntaub ntawv los ntawm scan 1
  • Daim duab 2 qhia pom Y1 & Y2 cov ntaub ntawv teeb pom kev zoo los ntawm scan 2
  • Daim duab 3 qhia cov duab xim… tsuas yog ib qho tsis raug… lub hnab yuav tsum ntsuab !!

Kuv yuav tshaj tawm cov cai tshiab thaum kuv tau daws qhov program no …

Cov ntaub ntawv:

[1]

www.haoyuelectronics.com/Attachment/OV7670%… (nplooj ntawv 33)

[2]

en.wikipedia.org/wiki/YCbCr (hloov dua siab tshiab JPEG)

Nyem qhov no mus saib kuv lwm cov ntawv qhia.

Pom zoo: