OV7670 Schwarz -Weiß -Bildaufnahme - Kontrast und Helligkeit
Posted: 19 Aug 2025, 11:42
Ich habe eine OV7670 -Kamera, die ich auf den Modus YUV eingestellt habe. Mit nur den Y -Bytes möchte ich schwarz -weiße Bilder haben, um einen Aruco -Marker zu erkennen. Die UC, die ich verwende, ein NRF9161 ist gering im Speicher und ich brauche keine Farbinformationen. /> Versuchen Sie, mit der Helligkeit und dem Kontrast nicht viel weiter zu fassen, aber die Verwendung des Datenblattblatts hilft mir auch in Bezug auf das, was diese Werte genau anzeigen
Code: Select all
{0x11, 0x06}, // CLKRC (prescaler set to 0x06 per your request)
{0x12, 0x00}, // COM7: Select YUV
{0x15, 0x20}, // COM10: per your request (PCLK polarity rising)
{0x8C, 0x00}, // RGB444 disable
{0x40, 0x10}, // COM15: Full range output, YUV422
{0x3A, 0x00}, // TSLB: YUYV order
{0x32, 0x80}, // HREF control
{0x17, 0x16}, // HSTART
{0x18, 0x04}, // HSTOP
{0x19, 0x02}, // VSTART
{0x1A, 0x7A}, // VSTOP
{0x03, 0x0A}, // VREF
{0x0C, 0x00}, // COM3: No scaling, no DCW
{0x3E, 0x00}, // COM14: No scaling, normal PCLK
{0x70, 0x3A}, // Scaling Xsc
{0x71, 0x35}, // Scaling Ysc
{0x72, 0x11}, // Scaling DCWCTR
{0x73, 0xF0}, // Scaling PCLK divider
{0xA2, 0x02}, // PCLK delay
//
{0x4F, 0x80},
{0x50, 0x80},
{0x51, 0x00},
{0x52, 0x22},
{0x53, 0x5E},
{0x54, 0x80},
{0x55, 0x00}, // BRIGHTNESS (default 0x00)
{0x56, 0x40}, // Contrast (default 0x40)
{0xFF, 0xFF}, // END marker
< /code>
(Ich sende einen Reset mit einer Verzögerung von 10 ms vorne) < /p>
Mein Bild erfasst Code: < /p>
void capture_image(uint8_t *p_bytes, int *p_byte_counter) {
*p_bytes = 0;
uint8_t bit_counter = 0;
bool odd = true;
uint8_t byte = 0;
// Disable interrupts for timing critical section
unsigned int key = irq_lock();
wait_for_vsync();
while(!get_value(VSYNC_PIN)) {
wait_for_low(PCLK_PIN, true); // unless VSYNC_PIN is set to high (true)
if(get_value(VSYNC_PIN)) break;
// Read pixel value (1 or 0)
uint8_t gpio = NRF_P0->IN;
uint8_t bit_d7 = !!(gpio & PIXEL_PIN_7_MASK);
// pixel contributes only if odd == true
if(odd) {
byte = (byte