-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Color distorted on ov5647 (AEGHB-907) #16
Comments
To rule out the display side, I've added a few coloured squares directly into the buffer, which seems to work. Colors are reproduced correctly: I've tried byte endian swap, bit endian swap, but no luck getting the output right. If I read through the esp_video examples, which all seem to product correct color reproduction, I don't see anything to suggest endianness issues or other pixel layouts, but maybe I'm missing something. |
This is a known issue that is currently being fixed. I believe there will be a new MR this week to solve this issue. |
Thank you, looking forward to the update. When it's released I'll test it and report back to close the issue. I also wanted to say thanks, these components are an impressive feat and makes handling camera operations so much more feasible! |
I might be impatient and it's not complete, but I just tested 6f07326 and the color distortion looks the same. This is with MIPI_2lane_24Minput_RAW8_800x800_50fps. I tried changing the bayer format, but they all looked the same, so maybe something else is still missing. I tested all formats, the RAW8 are all the same, the RAW10 formats produce complete noise. While writing this, I did some more testing and tried to set Now it also makes sense why the demos worked, as they do not flip the image! |
A second thing I noticed with this change is that it looks like the auto-exposure is turned off on some formats. It's very easy to completely blow out the picture by adding a light. |
It's easy to reproduce with
to the end of With value 0 (no HFLIP) this is the result: I'll also test with the SC2336 camera. |
Yes, if flip is enabled, this may require updating its bayer fmt. Because this flip feature comes from the sensor, it affects the Bayer format of RAW format. |
Color reproduction with LVGL 9.2 is good for all other screens, including when the camera is not swapped. I'm using esp_lvgl_port This also shows on the picture with the small RGB squares, they come out as intended. If I disable |
IMO horizontal flip is a mandatory feature, as it's usage is determined which way the camera is facing. If the camera is pointing the same way as the screen (e.g. a 'selfie' mode), the video doesn't need to be flipped, and the image makes sense as if you're looking into a mirror. If the camera is pointing through the screen (by lack of better terminology), the video needs to be flipped, otherwise everything is mirrored where it shouldn't be. I have the camera facing away from the screen and everything is mirrored: I hope this makes sense. I can try to fix the bayer demosaic for this sensor, but that would negate the tremendous advantage of the esp_video components with support for so many different sensors. Addition: you can test this with your phone. If you use the selfie camera the preview is mirrored. If you use the back camera the preview is not mirrored. |
Yes, the mirroring function affects the format of Bayer. Regarding the issue of sensor initialization, we made a bold attempt to allow the initialization list to be placed in the application layer code instead of always relying on the initialization list in esp-video. You can customize an initialization list and modify the bayer fmt in the structure describing the initialization list. |
If the bayer format should be adjusted, that wouldn't happen in the sensor initialisation, but in the ISP pipeline, or am I mistaken? I've seen the ISP controller, but I'm not sure how to go about that to adjust the bayer demosaic configuration, or I haven't found an example of this yet. |
I tried setting bayer_type, but it looks like it's not being picked up, or something else is not working. I added the following code, right after
It sets the When I do the same experiment with HFLIP off, the colors are correct with every bayer_type. However, I would have expected the colors to break if I set the wrong bayer_type. |
If various bayer types are tried, the color is not normal. So this issue does not come from sensors or ISP. Perhaps it was mentioned earlier that the byte order of the LCD needs to be adjusted. |
I already reproduced the issue with the web server example, with `esp_cam_sensor` 0.7.1. Just set HFLIP to 1 to reproduce the issue.
|
This is a frame coming from Bayer type Other bayer types have no influence on the picture. I added the following code at the end of
I hope this helps. |
Thank you for reporting. In addition, I added testing by installing my camera upside down on my development board. When the Flip function from the sensor is enabled, the color will be abnormal. And tried various bayer types in different situations, but could not fix the abnormality of this color. |
Thank you very much for all your efforts on this issue. The camera is a Raspberry Pi Camera v1.3 connected with a reverse direction FPC cable, so it is indeed like the one to the right on your photo: I understand the Flip function changes the RAW pixel data, before the bayer demosaic. I don't know where exactly this is done, as I couldn't find the code for this, and it looks like the current bayer formats are not matching whatever the sensor is sending out. I guess it's not possible to configure a complete bayer demosaic matrix configuration? I do think either direction should work fine, as it depends on the orientation of the camera vs the display, so with the other camera in your photo I think you would need a horizontal flip if it would be used as a selfie camera. As I'm planning to have support for multiple camera modules in my project, using PPA to fix orientation and mirroring would be a better option, at least for now. I did look into it, but it looked quite complicated :-) Before closing this issue I have one more question: are there plans to support conversion to L8 (greyscale) with PPA? This would be very useful for f.e. QR decoding as that needs greyscale input. I can do this in pure C, but that takes quite a hit on the framerate. Once more thank you very much for all your input, it is highly appreciated. I'm very impressed with the video components, they do a lot of very heavy lifting! |
Yes, because the FPC installation direction is different, we cannot find a matching bayer type for the sensor you are currently using. Adjusting the installation direction of FPC or using PPA to complete rotation is a good choice. |
I found a solution! If I set register 0x3821 to 0x07 instead of 0x03, the colors are correct and the image is no longer flipped. esp-video-components/esp_cam_sensor/sensors/ov5647/private_include/ov5647_settings.h Line 352 in 0ee836b
This sets I'm not 100% sure, but I think before it has to do something with the combination of binning and mirroring. So, I think the HFLIP and possibly also VFLIP needs to toggle more than just bit 1, but I need to test a bit further for this. |
Picture of the test setup, with the Pi Camera v1.3, the ESP32P4 Eval board on the left and my phone on the background showing the color chart you posted earlier. In front is the ST7789 display showing the live feed, with correct orientation. One more question I forgot in my excitement: what do you mean by 'adjusting the installation direction of FPC'? I can't put another cable on it, as that doesn't work electrically, but maybe I'm misunderstanding you. |
Checklist
How often does this bug occurs?
always
Expected behavior
Proper color reproduction. I have a test image, picture takes with my phone:
Colors are good when running f.e. the
simple_video_server_example
:Picture is flipped, but color reproduction is correct.
Actual behavior (suspected bug)
I'm trying to capture frames and show them on an LVGL 9 RGB565 canvas, on an ST7789 display. I push the frame to the canvas, I get the following result:
The display is only 320x240, and this is unscaled so it's a small crop of the frame buffer.
Error logs or terminal output
No response
Steps to reproduce the behavior
I've takes the setup code from the esp_video_server_example, set up the capture format:
Reading back the format shows it's set up as RGB565.
The deviation from the video_server_example is the capture loop, instead of reading the fd and push it into a JPEG converter, I push the frame directly onto an lv_image:
Project release version
0.7.0
System architecture
Intel/AMD 64-bit (modern PC, older Mac)
Operating system
Linux
Operating system version
Ubuntu 24.04
Shell
Bash
Additional context
ESP32P4 Function Evaluation Board chip revision: v0.1
ESP-IDF v5.4-dev-4291-g7a305c0284-dirty 2nd stage bootloader
Dependencies:
Maybe similar to #8 ?
The only setting in sdkconfig.default is
CONFIG_CAMERA_OV5647=y
, the rest is not altered from default value.The text was updated successfully, but these errors were encountered: