Arduino camera ov7670

Подключаем камеру OV7670 к Arduino и выводим картинку на дисплей

Данная камера ov7670 является самым доступным модулем для получения изображения совместно с Arduino.

Модуль камеры имеет следующие характеристики:

  • различные разрешение VGA (640 х 480); — QVGA (320 х 240); — CIF (352 х 240); — QCIF (176 × 144);
  • скорость передачи до 30 fps,
  • несколько способов кодирование изображения RAW RGB, RGB 565/555, YUV/YCbCr 4:2:2

В данной статье попробуем подключить, настроить и получить тестовое изображение с помощью небольшой программки написанной в среде Arduino IDE, что станет начальной точкой для дальнейшего применения в различных проектах.

Подключение OV7670 к Arduino

Начнем с сборки схемы и написания программы управления. Итак для сборки и отладки тестового макета нам потребуется :

Внешний вид макета

После того как Все компоненты собраны, приступаем к сборке схемы.

Чтобы не запутаться в схеме, для наглядности, распишем что и куда подключается:

Программа для трансляции видео с камеры на tft дисплее

Для работы с камерой и дисплеем совместно с Arduino нам понадобится, библиотеки: LiveOV7670Library и Adafruit_GFX_Library. Скачиваем их и устанавливаем в Arduino IDE. Теперь все готово для загрузки программы в Arduino.

Код состоит из нескольких частей. После скачивания и распаковки, все файлы следует сохранить в одной папке. Ссылка на скачивание проекта. После загрузки кода и проверки схемы, мы сразу получаем картинку ту что видит камера, не забыв настроить фокусировку.

После проверки работоспособности, можно перейти в скетче на вкладу setup.h

и изменив значение EXAMPLE 1 на EXAMPLE 3, камера будет транслировать изображение напрямую на экран монитора, при условии, что arduino подключена к компьютеру и запущена программа Arduino IDE.

При значение EXAMPLE 1 камера совместно с библиотекой LiveOV7670Library, передает картинку напрямую на дисплей подключенный по SPI интерфейсу.

Заключение

Данный пример работы камеры можно использовать как камеру видео наблюдения добавив к arduino LAN или же как зрение к роботу. Так же возможно использовать в виде WEB-камеры для компьютера.

Источник

Подключение камеры к Arduino

В данной статье мы рассматриваем подключение камеры OV7670 к Arduino. Этот модуль выбран не случайно — он является самым доступным устройством на рынке (среди аналогов) с неплохими функциональными характеристиками (скорость передачи до 30 fps, несколько способов кодировки изображений и др.).

Если вы хотите попробовать настроить web-камеру для видеонаблюдения или пробуете себя в конструировании игрушек со встроенной видеокамерой (роботов, радиоуправляемых машинок) – вам точно пригодится наша небольшая инструкция по этой теме.

Для сборки нам потребуются:

  • Arduino Uno;
  • макетная плата;
  • камера OV7670 (с разрешением 0,3 МП.);
  • соединительные провода.

Все эти компоненты можно приобрести практически в любом онлайн магазине. Стоимость очень демократичная, доставка быстрая.
Схема подключения будет такой, как показано на скриншоте:

Для связи аналоговой камеры и среды Arduino нам понадобятся сразу несколько библиотек: Adafruit_VC0706, SdFat и SdFatUtil (для SD карты), Ethernet (для Ethernet-шилда), SoftwareSerial (для камеры). Для других проектов может использоваться дополнительный специализированный софт — LiveOV7670Library и Adafruit_GFX_Library. По традиции скачиваем ПО, а затем инсталлируем в соответствующую папку с приложением (libraries).
Теперь можем прописывать программный скетч:
Не знаете, как подключить камеру к Ардуино? – Тут нет ничего сложного, зато какие открываются перспективы! Вы сможете придумать и воплотить в жизнь множество современных интересных проектов, в которых необходимо задействовать видеоаппаратуру. Не бойтесь экспериментов!

Источник

adafruit/Adafruit_OV7670

Use Git or checkout with SVN using the web URL.

Work fast with our official CLI. Learn more.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Adafruit OV7670 Library

Arduino library for OV7670 cameras, built over a C foundation common to both Arduino and (later) CircuitPython.

PLEASE NOTE: I’m setting this repository public since some folks had a specific need and wanted early access. It is ABSOLUTELY 100% GUARANTEED that there will be BREAKING CHANGES before this library is firmed up and considered «official,» so don’t get too comfortable with things being as they are.

These notes are primarily to assist with porting to new devices and in creating a CircuitPython library from the lower-level code. For using the library, see the included Arduino example(s).

To understand, discuss and adapt the code, a basic vernacular should be established. The terms chosen here are probably not optimal, but applied consistently will suffice in allowing different elements of the code to be discussed relative to one another. These are the terms used in the comments and in naming of structures and types.

An «architecture» refers to a related family of microcontroller devices where certain peripherals are implemented in-common. For example, SAMD51 is an architecture distinct from SAMD21 (though both ARM-based), because these have a different range of peripherals, and even when there’s functional overlap, the registers for configuring these peripherals are often a bit different. (Note that SAMD51 is initially the only supported architecture, and the mention of SAMD21 is purely hypothetical and might never happen. Others might be added in the future — STM32, i.MX, etc. — the code is written with that in mind even though there’s currently just one architecture.)

«Platform» as used in this code refers to a runtime environment, such as Arduino or CircuitPython. Could just as easily been «environment» or «language» or something else, but we’ll use «platform,» it’s good enough.

«Host» refers to a specific combination of architecture and platform (along with a list of pins to which an OV7670 camera is connected). Picture a table with architectures along one axis and platforms along the other. «SAMD51 Arduino» is one host, «SAMD51 CircuitPython» is another.

The project is written in a combination of C and C++. The C++ parts are currently intended for the Arduino platform. CircuitPython development requires C at present, so most lower-level functionality is implemented in that language. The C part itself has two layers. one «mid layer» set of functions that are common to all architectures, and a «lower» layer that does architecture-specific things such as accessing peripheral registers. CircuitPython support, when implemented, will probably have its own topmost C layer, akin to the Arduino C++ layer.

The code makes a reasonable attempt to keep architecture and platform -neutral vs -dependent C or C++ code in separate files. There might be a few exceptions with #ifdefs around them, always documented in the source. Also in comments, the terms «neutral» or «agnostic» might be used in different places, but same intent: non-preferential.

SPIBrute Arduino class

An extra class in here called «SPIBrute» is NOT RELATED to the OV7670 camera itself. This SAMD51-specific class can be used to issue data to SPI-connected displays when DMA is not enabled in Adafruit_SPITFT.h (part of Adafruit_GFX). It’s just a constructor and a couple functions. These display writes are still blocking operations, but the timing is particularly tight and avoids small inter-byte delays sometimes seen with SPI.transfer(), that’s all.

Architecture- and/or platform-specific files should contain #ifdef checks since some platforms (e.g. Arduino) will wanton compile all source files in the directory and would otherwise break.

When adding support for a new device at the C level, you MUST #include the corresponding header file in ov7670.h, so the C and C++ code that build atop this will pick up the specifics for the device.

Finer details are in comments peppered throughout the source.

The Arduino library and examples make use of an architecture-specific «arch» structure. This is kind of gross, but after much deliberation it seemed just slightly less gross than the alternative. There’s some notes in the .cpp.

The functions in image_ops.c perform postprocessing on a captured OV7670 image. These are not in-camera effects, though some might be possible to implement as such. Image is overwritten — destination buffer is always the same as the source buffer, same dimensions, same colorspace.

Data from the OV7670 is always in BIG-ENDIAN format. Most 16-bit TFT and OLED displays are also big-endian, so it’s straightforward to move data directly from one to the other. If you processing the image though. most microcontrollers are little-endian, so anything interpreting colors of an image will usually need to byte-swap the data, e.g. for each pixel:

RGR565 and YUV output are supported. RGB444 and RGB555 are of questionable utility so I’m not bothering. A function is provided to convert YUV to a grayscale big-endian RGB565 representation for output to TFT displays. If not displaying, if you only need the grayscale (0-255) value of a pixel, use the LSB of a 16-bit YUV pixel (don’t covert to RGB565, as this will decimate the grayscale resolution).

The library currently provides five resolution settings from full VGA (640×480 pixels, RAM permitting, which it isn’t), and powers-of-two divisions of this, down to 1:16 (40×30 pixels).

An intentional choice was made to ignore the camera’s CIF resolution options for the sake of getting things done. CIF is an antiquated throwback to analog PAL video and doesn’t really get us much, being just slightly larger than the nearest corresponding VGA division anyway.

IN THEORY the camera can provide nearly any resolution from CIF down to 40×30, with independent scaling on each axis. In practice this has proven difficult to implement, as it’s not well explained in documentation or example code. Maybe this will be revisited in the future if it’s needed, at which point CIF (and any other resolution) will happen implicitly. But for now, just the VGA powers-of-two.

At the smallest size (40×30), there are artifacts in the first row and column that I’ve not been able to eliminate. Any software using this setting should try to mask out or otherwise ignore those pixels.

Источник

How to Use OV7670 Camera Module with Arduino​

Cameras have always dominated the electronics industry as it has lots of applications such as visitor monitoring system, surveillance system, attendance system etc. Cameras that we use today are smart and have a lot of features that were not present in earlier cameras. While todays digital cameras not only capture images but also captures high-level descriptions of the scene and analyse what they see. It is used extensively in Robotics, Artificial Intelligence, Machine Learning etc. The Captured frames are processed using Artificial Intelligence and Machine Learning, and then used in many applications like Number plate detection, object detection, motion detection, facial recognition etc.

In this tutorial we will interface most widely used camera module OV7670 with Arduino UNO. The camera module OV7670 can be interfaced with Arduino Mega with same pin configuration, code and steps. The camera module is hard to interface because it has large number of pins and jumbled wiring to carry out. Also the wire becomes very important when using camera modules as the choice of the wire and length of the wire can significantly affect the picture quality and can bring noise.

We have already done ample projects on Cameras with different kind of Microcontrollers and IoT Devices such as:

The Camera OV7670 works on 3.3V, so it becomes very important to avoid Arduino which gives 5V output at their Output GPIO pins. The OV7670 is a FIFO camera. But in this tutorial, the picture or frames will be grabbed without FIFO. This tutorial will have simple steps and simplified programming to interface OV7670 with Arduino UNO.

Components Required

  • Arduino UNO
  • OV7670 Camera Module
  • Resistors(10k, 4.7k)
  • Jumpers

Software Required:

Things to Remember about Camera Module OV7670

OV7670 Camera Module is a FIFO camera Module available from different Manufacturers with different pin Configurations. TheOV7670 provides full frame, windowed 8-bit images in a wide range of formats. The image array is capable of operating at up to 30 frames per second (fps) in VGA. The OV7670 includes

  • Image Sensor Array(of about 656 x 488 pixels)
  • Timing Generator
  • Analog Signal Processor
  • A/D Converters
  • Test Pattern Generator
  • Digital Signal Processor(DSP)
  • Image Scaler
  • Digital Video Port
  • LED and Strobe Flash Control Output

The OV7670 image sensor is controlled using Serial Camera Control Bus (SCCB) which is an I2C interface (SIOC, SIOD) with a maximum clock frequency of 400KHz.

The Camera comes with handshaking signals such as:

  • VSYNC: Vertical Sync Output – Low during frame
  • HREF: Horizontal Reference – High during active pixels of row
  • PCLK: Pixel Clock Output – Free running clock. Data is valid on rising edge

In addition to this, it has several more signals such as

  • D0-D7: 8-bit YUV/RGB Video Component Digital Output
  • PWDN: Power Down Mode Selection – Normal Mode and Power Down Mode
  • XCLK: System Clock Input
  • Reset: Reset Signal

The OV7670 is clocked from a 24MHz oscillator. This gives a Pixel Clock(PCLK) output of 24MHz. The FIFO provides 3Mbps of video frame buffer memory. The test pattern generator features 8-bar color bar pattern, fade-to-gray color bar patter. Now let’s start programming the Arduino UNO for testing Camera OV7670 and grabbing frames using serial port reader.

Circuit Diagram

Programming Arduino UNO

After this, the registers need to be modified for OV7670. The program is divided into small functions for better understanding.

The Setup() comprises all the initial setups required for only image capturing. The first function is arduinoUnoInut() which is used to initialise the arduino uno. Initially it disables all the global interrupts and sets the communication interface configurations such as the PWM clock, selection of interrupt pins, presclaer selection, adding parity and stop bits.

After configuring the Arduino, the camera has to be configured. To initialise the camera, we only have the options to change the register values. The register values need to be changed from the default to the custom. Also add required delay depending upon the microcontroller frequency we are using. As, slow microcontrollers have less processing time adding more delay between capturing frames.

The camera is set to take a QVGA image so the resolution need to be selected. The function configures the register to take a QVGA image.

In this tutorial, the images are taken in monochrome, so the register value is set to output a monochrome image. The function sets the register values from register list which is predefined in the program.

The below function is write to register function which writes the hex value to register. If you get the scrambled images then try to change the second term i.e. 10 to 9/11/12. But most of the time this value works fine so no need to change it.

This function is used to get the image resolution size. In this project we are taking pictures in the size of 320 x 240 pixels.

Other than this, the code also has the I2C configurations divided in to several parts. Just to get the data from camera, the I2C configurations has Start, Read, Write, Set Address function which are important when using I2C protocol.

You can find the complete code with a demonstration video at the end of this tutorial. Just Upload the code and open the Serial Port Reader and grab the frames.

How to Use Serial Port Reader for reading Images

Step 1: Connect Your Arduino to any USB Port of your PC

Step 2: Click on “Check” to find your Arduino COM Port

Step 3: Finally click on “Start” button to start reading serially.

Step 4: One can also save this pictures by just clicking on “Save Picture”.

Below are Sample Images Taken from the OV7670

Precautions when using OV7670

  • Try to use wires or jumpers as short as possible
  • Avoid any loose contact to any pins on Arduino or OV7670
  • Be careful about connecting as large number of wiring can lead short circuit
  • If the UNO gives 5V output to GPIO then use Level Shifter.
  • Use 3.3V Input for OV7670 as exceeding voltage than this can damage the OV7670 module.

This project is created to give overview of using a camera module with Arduino. Since Arduino has less memory, so the processing may not be as expected. You can use different controllers which has more memory for processing.

#define F_CPU 16000000UL
#define vga 0
#define qvga 1
#define qqvga 2
#define yuv422 0
#define rgb565 1
#define bayerRGB 2
#define camAddr_WR 0x42
#define camAddr_RD 0x43

/* Registers */
#define REG_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */
#define REG_BLUE 0x01 /* blue gain */
#define REG_RED 0x02 /* red gain */
#define REG_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */
#define REG_COM1 0x04 /* Control 1 */
#define COM1_CCIR656 0x40 /* CCIR656 enable */

#define REG_BAVE 0x05 /* U/B Average level */
#define REG_GbAVE 0x06 /* Y/Gb Average level */
#define REG_AECHH 0x07 /* AEC MS 5 bits */
#define REG_RAVE 0x08 /* V/R Average level */
#define REG_COM2 0x09 /* Control 2 */
#define COM2_SSLEEP 0x10 /* Soft sleep mode */
#define REG_PID 0x0a /* Product ID MSB */
#define REG_VER 0x0b /* Product ID LSB */
#define REG_COM3 0x0c /* Control 3 */
#define COM3_SWAP 0x40 /* Byte swap */
#define COM3_SCALEEN 0x08 /* Enable scaling */
#define COM3_DCWEN 0x04 /* Enable downsamp/crop/window */
#define REG_COM4 0x0d /* Control 4 */
#define REG_COM5 0x0e /* All «reserved» */
#define REG_COM6 0x0f /* Control 6 */
#define REG_AECH 0x10 /* More bits of AEC value */
#define REG_CLKRC 0x11 /* Clocl control */
#define CLK_EXT 0x40 /* Use external clock directly */
#define CLK_SCALE 0x3f /* Mask for internal clock scale */
#define REG_COM7 0x12 /* Control 7 */ //REG mean address.
#define COM7_RESET 0x80 /* Register reset */
#define COM7_FMT_MASK 0x38
#define COM7_FMT_VGA 0x00
#define COM7_FMT_CIF 0x20 /* CIF format */
#define COM7_FMT_QVGA 0x10 /* QVGA format */
#define COM7_FMT_QCIF 0x08 /* QCIF format */
#define COM7_RGB 0x04 /* bits 0 and 2 — RGB format */
#define COM7_YUV 0x00 /* YUV */
#define COM7_BAYER 0x01 /* Bayer format */
#define COM7_PBAYER 0x05 /* «Processed bayer» */
#define REG_COM8 0x13 /* Control 8 */
#define COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */
#define COM8_AECSTEP 0x40 /* Unlimited AEC step size */
#define COM8_BFILT 0x20 /* Band filter enable */
#define COM8_AGC 0x04 /* Auto gain enable */
#define COM8_AWB 0x02 /* White balance enable */
#define COM8_AEC 0x01 /* Auto exposure enable */
#define REG_COM9 0x14 /* Control 9- gain ceiling */
#define REG_COM10 0x15 /* Control 10 */
#define COM10_HSYNC 0x40 /* HSYNC instead of HREF */
#define COM10_PCLK_HB 0x20 /* Suppress PCLK on horiz blank */
#define COM10_HREF_REV 0x08 /* Reverse HREF */
#define COM10_VS_LEAD 0x04 /* VSYNC on clock leading edge */
#define COM10_VS_NEG 0x02 /* VSYNC negative */
#define COM10_HS_NEG 0x01 /* HSYNC negative */
#define REG_HSTART 0x17 /* Horiz start high bits */
#define REG_HSTOP 0x18 /* Horiz stop high bits */
#define REG_VSTART 0x19 /* Vert start high bits */
#define REG_VSTOP 0x1a /* Vert stop high bits */
#define REG_PSHFT 0x1b /* Pixel delay after HREF */
#define REG_MIDH 0x1c /* Manuf. ID high */
#define REG_MIDL 0x1d /* Manuf. ID low */
#define REG_MVFP 0x1e /* Mirror / vflip */
#define MVFP_MIRROR 0x20 /* Mirror image */
#define MVFP_FLIP 0x10 /* Vertical flip */

#define REG_AEW 0x24 /* AGC upper limit */
#define REG_AEB 0x25 /* AGC lower limit */
#define REG_VPT 0x26 /* AGC/AEC fast mode op region */
#define REG_HSYST 0x30 /* HSYNC rising edge delay */
#define REG_HSYEN 0x31 /* HSYNC falling edge delay */
#define REG_HREF 0x32 /* HREF pieces */
#define REG_TSLB 0x3a /* lots of stuff */
#define TSLB_YLAST 0x04 /* UYVY or VYUY — see com13 */
#define REG_COM11 0x3b /* Control 11 */
#define COM11_NIGHT 0x80 /* NIght mode enable */
#define COM11_NMFR 0x60 /* Two bit NM frame rate */
#define COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */
#define COM11_50HZ 0x08 /* Manual 50Hz select */
#define COM11_EXP 0x02
#define REG_COM12 0x3c /* Control 12 */
#define COM12_HREF 0x80 /* HREF always */
#define REG_COM13 0x3d /* Control 13 */
#define COM13_GAMMA 0x80 /* Gamma enable */
#define COM13_UVSAT 0x40 /* UV saturation auto adjustment */
#define COM13_UVSWAP 0x01 /* V before U — w/TSLB */
#define REG_COM14 0x3e /* Control 14 */
#define COM14_DCWEN 0x10 /* DCW/PCLK-scale enable */
#define REG_EDGE 0x3f /* Edge enhancement factor */
#define REG_COM15 0x40 /* Control 15 */
#define COM15_R10F0 0x00 /* Data range 10 to F0 */
#define COM15_R01FE 0x80 /* 01 to FE */
#define COM15_R00FF 0xc0 /* 00 to FF */
#define COM15_RGB565 0x10 /* RGB565 output */
#define COM15_RGB555 0x30 /* RGB555 output */
#define REG_COM16 0x41 /* Control 16 */
#define COM16_AWBGAIN 0x08 /* AWB gain enable */
#define REG_COM17 0x42 /* Control 17 */
#define COM17_AECWIN 0xc0 /* AEC window — must match COM4 */
#define COM17_CBAR 0x08 /* DSP Color bar */
/*
* This matrix defines how the colors are generated, must be
* tweaked to adjust hue and saturation.
*
* Order: v-red, v-green, v-blue, u-red, u-green, u-blue
* They are nine-bit signed quantities, with the sign bit
* stored in0x58.Sign for v-red is bit 0, and up from there.
*/
#define REG_CMATRIX_BASE 0x4f
#define CMATRIX_LEN 6
#define REG_CMATRIX_SIGN 0x58
#define REG_BRIGHT 0x55 /* Brightness */
#define REG_CONTRAS 0x56 /* Contrast control */
#define REG_GFIX 0x69 /* Fix gain control */
#define REG_REG76 0x76 /* OV’s name */
#define R76_BLKPCOR 0x80 /* Black pixel correction enable */
#define R76_WHTPCOR 0x40 /* White pixel correction enable */
#define REG_RGB444 0x8c /* RGB 444 control */
#define R444_ENABLE 0x02 /* Turn on RGB444, overrides 5×5 */
#define R444_RGBX 0x01 /* Empty nibble at end */
#define REG_HAECC1 0x9f /* Hist AEC/AGC control 1 */
#define REG_HAECC2 0xa0 /* Hist AEC/AGC control 2 */
#define REG_BD50MAX 0xa5 /* 50hz banding step limit */
#define REG_HAECC3 0xa6 /* Hist AEC/AGC control 3 */
#define REG_HAECC4 0xa7 /* Hist AEC/AGC control 4 */
#define REG_HAECC5 0xa8 /* Hist AEC/AGC control 5 */
#define REG_HAECC6 0xa9 /* Hist AEC/AGC control 6 */
#define REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */
#define REG_BD60MAX 0xab /* 60hz banding step limit */
#define REG_GAIN 0x00 /* Gain lower 8 bits (rest in vref) */
#define REG_BLUE 0x01 /* blue gain */
#define REG_RED 0x02 /* red gain */
#define REG_VREF 0x03 /* Pieces of GAIN, VSTART, VSTOP */
#define REG_COM1 0x04 /* Control 1 */
#define COM1_CCIR656 0x40 /* CCIR656 enable */
#define REG_BAVE 0x05 /* U/B Average level */
#define REG_GbAVE 0x06 /* Y/Gb Average level */
#define REG_AECHH 0x07 /* AEC MS 5 bits */
#define REG_RAVE 0x08 /* V/R Average level */
#define REG_COM2 0x09 /* Control 2 */
#define COM2_SSLEEP 0x10 /* Soft sleep mode */
#define REG_PID 0x0a /* Product ID MSB */
#define REG_VER 0x0b /* Product ID LSB */
#define REG_COM3 0x0c /* Control 3 */
#define COM3_SWAP 0x40 /* Byte swap */
#define COM3_SCALEEN 0x08 /* Enable scaling */
#define COM3_DCWEN 0x04 /* Enable downsamp/crop/window */
#define REG_COM4 0x0d /* Control 4 */
#define REG_COM5 0x0e /* All «reserved» */
#define REG_COM6 0x0f /* Control 6 */
#define REG_AECH 0x10 /* More bits of AEC value */
#define REG_CLKRC 0x11 /* Clocl control */
#define CLK_EXT 0x40 /* Use external clock directly */
#define CLK_SCALE 0x3f /* Mask for internal clock scale */
#define REG_COM7 0x12 /* Control 7 */
#define COM7_RESET 0x80 /* Register reset */
#define COM7_FMT_MASK 0x38
#define COM7_FMT_VGA 0x00
#define COM7_FMT_CIF 0x20 /* CIF format */
#define COM7_FMT_QVGA 0x10 /* QVGA format */
#define COM7_FMT_QCIF 0x08 /* QCIF format */
#define COM7_RGB 0x04 /* bits 0 and 2 — RGB format */
#define COM7_YUV 0x00 /* YUV */
#define COM7_BAYER 0x01 /* Bayer format */
#define COM7_PBAYER 0x05 /* «Processed bayer» */
#define REG_COM8 0x13 /* Control 8 */
#define COM8_FASTAEC 0x80 /* Enable fast AGC/AEC */
#define COM8_AECSTEP 0x40 /* Unlimited AEC step size */
#define COM8_BFILT 0x20 /* Band filter enable */
#define COM8_AGC 0x04 /* Auto gain enable */
#define COM8_AWB 0x02 /* White balance enable */
#define COM8_AEC 0x01 /* Auto exposure enable */
#define REG_COM9 0x14 /* Control 9- gain ceiling */
#define REG_COM10 0x15 /* Control 10 */
#define COM10_HSYNC 0x40 /* HSYNC instead of HREF */
#define COM10_PCLK_HB 0x20 /* Suppress PCLK on horiz blank */
#define COM10_HREF_REV 0x08 /* Reverse HREF */
#define COM10_VS_LEAD 0x04 /* VSYNC on clock leading edge */
#define COM10_VS_NEG 0x02 /* VSYNC negative */
#define COM10_HS_NEG 0x01 /* HSYNC negative */
#define REG_HSTART 0x17 /* Horiz start high bits */
#define REG_HSTOP 0x18 /* Horiz stop high bits */
#define REG_VSTART 0x19 /* Vert start high bits */
#define REG_VSTOP 0x1a /* Vert stop high bits */
#define REG_PSHFT 0x1b /* Pixel delay after HREF */
#define REG_MIDH 0x1c /* Manuf. ID high */
#define REG_MIDL 0x1d /* Manuf. ID low */
#define REG_MVFP 0x1e /* Mirror / vflip */
#define MVFP_MIRROR 0x20 /* Mirror image */
#define MVFP_FLIP 0x10 /* Vertical flip */
#define REG_AEW 0x24 /* AGC upper limit */
#define REG_AEB 0x25 /* AGC lower limit */
#define REG_VPT 0x26 /* AGC/AEC fast mode op region */
#define REG_HSYST 0x30 /* HSYNC rising edge delay */
#define REG_HSYEN 0x31 /* HSYNC falling edge delay */
#define REG_HREF 0x32 /* HREF pieces */
#define REG_TSLB 0x3a /* lots of stuff */
#define TSLB_YLAST 0x04 /* UYVY or VYUY — see com13 */
#define REG_COM11 0x3b /* Control 11 */
#define COM11_NIGHT 0x80 /* NIght mode enable */
#define COM11_NMFR 0x60 /* Two bit NM frame rate */
#define COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */
#define COM11_50HZ 0x08 /* Manual 50Hz select */
#define COM11_EXP 0x02
#define REG_COM12 0x3c /* Control 12 */
#define COM12_HREF 0x80 /* HREF always */
#define REG_COM13 0x3d /* Control 13 */
#define COM13_GAMMA 0x80 /* Gamma enable */
#define COM13_UVSAT 0x40 /* UV saturation auto adjustment */
#define COM13_UVSWAP 0x01 /* V before U — w/TSLB */
#define REG_COM14 0x3e /* Control 14 */
#define COM14_DCWEN 0x10 /* DCW/PCLK-scale enable */
#define REG_EDGE 0x3f /* Edge enhancement factor */
#define REG_COM15 0x40 /* Control 15 */
#define COM15_R10F0 0x00 /* Data range 10 to F0 */
#define COM15_R01FE 0x80 /* 01 to FE */
#define COM15_R00FF 0xc0 /* 00 to FF */
#define COM15_RGB565 0x10 /* RGB565 output */
#define COM15_RGB555 0x30 /* RGB555 output */
#define REG_COM16 0x41 /* Control 16 */
#define COM16_AWBGAIN 0x08 /* AWB gain enable */
#define REG_COM17 0x42 /* Control 17 */
#define COM17_AECWIN 0xc0 /* AEC window — must match COM4 */
#define COM17_CBAR 0x08 /* DSP Color bar */

#define CMATRIX_LEN 6
#define REG_BRIGHT 0x55 /* Brightness */
#define REG_REG76 0x76 /* OV’s name */
#define R76_BLKPCOR 0x80 /* Black pixel correction enable */
#define R76_WHTPCOR 0x40 /* White pixel correction enable */
#define REG_RGB444 0x8c /* RGB 444 control */
#define R444_ENABLE 0x02 /* Turn on RGB444, overrides 5×5 */
#define R444_RGBX 0x01 /* Empty nibble at end */
#define REG_HAECC1 0x9f /* Hist AEC/AGC control 1 */
#define REG_HAECC2 0xa0 /* Hist AEC/AGC control 2 */
#define REG_BD50MAX 0xa5 /* 50hz banding step limit */
#define REG_HAECC3 0xa6 /* Hist AEC/AGC control 3 */
#define REG_HAECC4 0xa7 /* Hist AEC/AGC control 4 */
#define REG_HAECC5 0xa8 /* Hist AEC/AGC control 5 */
#define REG_HAECC6 0xa9 /* Hist AEC/AGC control 6 */
#define REG_HAECC7 0xaa /* Hist AEC/AGC control 7 */
#define REG_BD60MAX 0xab /* 60hz banding step limit */
#define MTX1 0x4f /* Matrix Coefficient 1 */
#define MTX2 0x50 /* Matrix Coefficient 2 */
#define MTX3 0x51 /* Matrix Coefficient 3 */
#define MTX4 0x52 /* Matrix Coefficient 4 */
#define MTX5 0x53 /* Matrix Coefficient 5 */
#define MTX6 0x54 /* Matrix Coefficient 6 */
#define REG_CONTRAS 0x56 /* Contrast control */
#define MTXS 0x58 /* Matrix Coefficient Sign */
#define AWBC7 0x59 /* AWB Control 7 */
#define AWBC8 0x5a /* AWB Control 8 */
#define AWBC9 0x5b /* AWB Control 9 */
#define AWBC10 0x5c /* AWB Control 10 */
#define AWBC11 0x5d /* AWB Control 11 */
#define AWBC12 0x5e /* AWB Control 12 */
#define REG_GFI 0x69 /* Fix gain control */
#define GGAIN 0x6a /* G Channel AWB Gain */
#define DBLV 0x6b
#define AWBCTR3 0x6c /* AWB Control 3 */
#define AWBCTR2 0x6d /* AWB Control 2 */
#define AWBCTR1 0x6e /* AWB Control 1 */
#define AWBCTR0 0x6f /* AWB Control 0 */

struct regval_list <
uint8_t reg_num;
uint16_t value;
>;

const struct regval_list yuv422_ov7670[] PROGMEM = <
< REG_COM7, 0x0 >, /* Selects YUV mode */
< REG_RGB444, 0 >, /* No RGB444 please */
< REG_COM1, 0 >,
< REG_COM15, COM15_R00FF >,
< REG_COM9, 0x6A >, /* 128x gain ceiling; 0x8 is reserved bit */
< 0x4f, 0x80 >, /* «matrix coefficient 1» */
< 0x50, 0x80 >, /* «matrix coefficient 2» */
< 0x51, 0 >, /* vb */
< 0x52, 0x22 >, /* «matrix coefficient 4» */
< 0x53, 0x5e >, /* «matrix coefficient 5» */
< 0x54, 0x80 >, /* «matrix coefficient 6» */
< REG_COM13, COM13_UVSAT >,
< 0xff, 0xff >, /* END MARKER */
>;

Источник

Adblock
detector