Recently, I received a small imx477 camera for a project using the Zero 3W, and because the CSI connector is on the bottom, the camera image is upside down. I’m looking for a way to rotate the image 180º before grabbing the image, for example, by adjusting the image orientation using the registers. Unfortunately i can’t find enough information on the registers for that.
I have seen Jetson boards have similar issue and solved using libcamera rotate=180 , i don’t have enough knowledge on libcamera to check if it’s done by hardware (registers set) or the image is rotated on the fly, consuming CPU/VPU.
I tried something like this, but it did not work:
/*
* FORCE HORIZONTAL FLIP (MIRROR) DURING PROBE
* Register 0x0101: 0x01 = H-FLIP Enabled, 0x00 = Disabled
*/
dev_err(dev, "H-FLIP: %d - V-FLIP: %d\n", camera_default_hflip, camera_default_vflip);
if (camera_default_hflip) {
ret = imx477_write_reg(imx477, 0x0101, IMX477_REG_VALUE_08BIT, camera_default_hflip);
if (ret) {
dev_err(dev, "Failed to set H-FLIP\n");
}
}
if (camera_default_vflip) {
/* Force Vertical Flip (vflip) by writing to IMG_ORIENTATION (0x0171) */
ret = imx477_write_reg(imx477, 0x0171, IMX477_REG_VALUE_08BIT, camera_default_hflip);
if (ret) {
dev_err(dev, "Failed to set V-FLIP\n");
}
}
If i use RAW image, the HFLIP=1 and VFLIP=1 work just fine but as soon as the camera engine is working it reset HFLIP and VFLIP. Stopping the capture process and setting HFLIP and VFLIP works BUT the colors are switched.
here are some samples to illustrate it:
Rotating 180°:
Using the camera engine:
Rotation 180°
This is in initial stage but i used this code with attached patch to grab jpeg images:
fswebcam: ( GitHub - avafinger/fswebcam: fswebcam for H2 / H3 / A64 / Rockchip (exposure,Hflip and Vflip control set) · GitHub )
Capture with 50% qualitly:
fswebcam --displayfps 1 -S 90 -d /dev/video0 -r 4048x3040 --jpeg 50 -p NV12 - > 4048x3040.jpg
Display window size:
diff --git a/fswebcam.c b/fswebcam.c
index 3dc3e91..6459a6a 100644
— a/fswebcam.c
+++ b/fswebcam.c
@@ -363,7 +363,7 @@ int fswc_draw_overlay(fswebcam_config_t *config, char *filename, gdImage *image)
int fswc_draw_banner(fswebcam_config_t *config, gdImage *image)
{
char timestamp[200];
char FPS[32];
char FPS[64];
int w, h;
int height;
int spacing;
@@ -418,7 +418,7 @@ int fswc_draw_banner(fswebcam_config_t *config, gdImage *image)
/* Draw FPS */
if (config->display_fps) {
sprintf(FPS, "%d FPS - %s", config->captured_fps, config->src_palette);
sprintf(FPS, "%d FPS - %s - %dx%d", config->captured_fps, config->src_palette, w, h);
fprintf(stderr, "%s\n", FPS);
fswc_DrawText(image, config->font, config->fontsize,
spacing, y, ALIGN_LEFT,
print_window_size_on_banner.patch.zip (577 Bytes)





