Use MDP to flip and rotate the camera image
MDP is an image processing hardware that exists in the SoC and can be used through the v4l2 API or Gstreamer - v4l2convert.
The MDP video device has properties that can be set to rotate, flip,
horizontal_flip 0x00980914 (bool) : default=0 value=0
vertical_flip 0x00980915 (bool) : default=0 value=0
rotate 0x00980922 (int) : min=0 max=270 step=90 default=0 value=0 flags=modify-layout
In addition to setting the property, you also need to set the corresponding output buffer size. For example, if the input buffer is 1280*720 and is rotated 90 degrees, the output buffer will become 720*1280.
Here are some examples to rotate and flip the camera input through v4l2convert (mdp):
# Original:
gst-launch-1.0 -v v4l2src device=${VIDEO_DEV[0]} ! video/x-raw,width=1280,height=720,format=YUY2 ! v4l2convert output-io-mode=dmabuf-import capture-io-mode=dmabuf extra-controls="cid" ! 'video/x-raw, format=NV12' ! queue ! waylandsink
# Rotate 90 degrees:
gst-launch-1.0 -v v4l2src device=${VIDEO_DEV[0]} ! video/x-raw,width=1280,height=720,format=YUY2 ! v4l2convert output-io-mode=dmabuf-import capture-io-mode=dmabuf extra-controls="cid,rotate=90" ! 'video/x-raw, width=720, height=1280, pixel-aspect-ratio=(fraction)1/1, format=NV12' ! queue ! waylandsink
# horizontal flip
gst-launch-1.0 -v v4l2src device=${VIDEO_DEV[0]} ! video/x-raw,width=1280,height=720,format=YUY2 ! v4l2convert output-io-mode=dmabuf-import capture-io-mode=dmabuf extra-controls="cid,horizontal_flip=1" ! 'video/x-raw, format=NV12' ! queue ! waylandsink
# horizontal flip + Rotate 180 degrees:
gst-launch-1.0 -v v4l2src device=${VIDEO_DEV[0]} ! video/x-raw,width=1280,height=720,format=YUY2 ! v4l2convert output-io-mode=dmabuf-import capture-io-mode=dmabuf extra-controls="cid,rotate=180,horizontal_flip=1" ! 'video/x-raw, pixel-aspect-ratio=(fraction)1/1, format=NV12' ! queue ! waylandsink
# vertical flip:
gst-launch-1.0 -v v4l2src device=${VIDEO_DEV[0]} ! video/x-raw,width=1280,height=720,format=YUY2 ! v4l2convert output-io-mode=dmabuf-import capture-io-mode=dmabuf extra-controls="cid,vertical_flip=1" ! 'video/x-raw, format=NV12' ! queue ! waylandsink
# vertical flip + Rotate 270 degrees:
gst-launch-1.0 -v v4l2src device=${VIDEO_DEV[0]} ! video/x-raw,width=1280,height=720,format=YUY2 ! v4l2convert output-io-mode=dmabuf-import capture-io-mode=dmabuf extra-controls="cid,rotate=270,vertical_flip=1" ! 'video/x-raw, width=720, height=1280, pixel-aspect-ratio=(fraction)1/1, format=NV12' ! queue ! waylandsink