How to rotate camera view 90 degrees in Python when camera is mounted sideways

Hi everyone, I’ve got a camera mounted sideways inside my case and I need to rotate the camera view by 90 degrees. I’m recording videos from a Python script. Is there any way to rotate the view 90 degrees so the recorded video comes out the right way up?

That should be doable with the right setup. If you’re using a Raspberry Pi camera with picamera2, there’s an official rotation example in the picamera2 repo that’s the recommended reference for rotating the camera view in a Python script: picamera2/examples/rotation.py at main · raspberrypi/picamera2 · GitHub. Have a look at that and see if it fits your setup.

Thanks, I checked that rotation.py example, but it only seems to do horizontal and vertical flips, not a 90-degree rotation. My camera is the Raspberry Pi High Quality Camera IMX477, and it’s sideways because of how it mounts in the case. I really need a proper 90-degree rotation, not just a flip. Is that supported on this camera?

Based on what I can see, the IMX477 HQ camera only supports 180° rotation, not 90°. That’s why the rotation example only covers the flip cases. So unfortunately a true 90-degree rotation isn’t available for this camera, and the sideways mounting can’t be corrected that way in software.

That’s a problem then. If 90° rotation isn’t supported, is there any way to change which side the connector is on for the camera? That would let me mount it in the case the right way up instead.

Changing the connector side would require a hardware design change, so it isn’t something available on the standard product. That kind of modification is a customized board request. You’d need to contact the sales team at [email protected] so they can evaluate the feasibility and get back to you. But in short: a 90° rotation / connector-side change isn’t a standard option and would have to be handled as a custom hardware solution.