cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7A3 and camera problems

Matjaz Tome
Associate II

Hello,

I have a STM32H7A3 dev board (NUCLEO-H7A3ZI-Q) and have connected it to a OV7670 camera using DCMI interface. I used an example from Cube library (for DCMI) that grabs single image from camera and stores it in the internal RAM of a microcontroller. That part seems to work just fine, as the expected numbers of pixels actually get stored in the memory.

Then I wrote a simple Python script that receives that data throu UART and draws a picture.

The pictures I get are really strange (see attached photo). If i set my camera module to transmitt test patern, the bars are there, but the collors are different from what is expected.

This is the code that takes raw data from camera module and changes them to 3 8-bit varaibles (r, g, b):

 

 

 

static void data_to_rgb (uint8_t *in_data, uint8_t* r, uint8_t *g, uint8_t *b)
{
	uint8_t g_lower = 0;
	g_lower = (*(in_data + 1) & 0xE0) >> 3;
	*r = (*(in_data)) & (0xF8);
	*g = ((*(in_data) & 0x07) << 5 | g_lower);
	*b = (*(in_data + 1) & 0x1F)  << 3;

}

 

 

 

 

in_data is a pointer to memory where a data from camera is stored and r, g, b are pointers for r, g and b values of pixels. Camera is setup to transmitt data in RGB format at reolution of 320 x 240 pixels.

Any ideas what could be wrong?

2 REPLIES 2
KDJEM.1
ST Employee

Hello @Matjaz Tome,

 

Are you able to display capture data on your computer display?

For that, I recommend you to take a look to USB_Webcam application in FP-AI-VISION1 package.

FP-AI-VISION1_V3.1.0\Projects\STM32H747I-DISCO\Applications\USB_Webcam

This application enables the STM32H7 to act as a USB Video Camera device. Native USB video driver support is provided with Windows, Ubuntu and macOS.

 

I hope this help you!

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @KDJEM.1 

Thank you for your response. The image I attached to the previous post (no_magic.png) is the image I get on my computer.

I will have a look at the FP_AI_VISON1 package.

My concern is that mabye my camera module isn't configured correctly. There are a lot configuration registers for OV7670 and their fuction is not very well explained in datasheet.

I tried few different combinations of this registers from other sites (mostly forums with topics about Arduino) but haven't comm across a ST sollution.