CSI camera image flip on Jetson nano

Hi there,

I’ve just finished Hello AI World (following the examples in C++) and before moving forward I would to be able to flip the camera image 180. The disposition of camera while I was going through the examples was always upside down and for future reference it would be a good exercise to understand which Libs I need to use to accomplish that.

I’m still trying to navigate through all existing libraries, so I’m sorry if I’m missing something obvious.

In a simple example as the detection example it seems to be that after the “capture” function call it would be a good opportunity to work with that frame since it’s place in memory, thus:

  • Instead of using CaptureRGBA I would simple use Capture from gstCamera Class and get the GPU address space where that frame is.
  • Given that I have to transform that frame and flip it 180º, I imagine that something like the Buffer Surface API (NvBufSurface) or the Buffer Manager from the L4T Multimedia API could be used.

Could you please point me to the right direction? Is there a better option than using one of these libraries?

Thanks for your help in advance.

Best regards,

Have a check flip-method=2


Thank you Shane,

Thanks for the help and the quick response.

I’ll have a closer look this evening (German time), but at first glance it seems that it is related to gstreamer command lines to accomplish rotation. I guess I’ll have to look for the library in order to be able to use it before the detection.

Let me know if that was not your intention.


Yes, it’s a for the gstreamer command parameter.
There’s still have v4l2 video converter API for it. Have a check the multimedia API from the download center to check it.

Hi Shane,

When you say Multimedia API, are you referring to the L4T Multimedia API?

I can find some code examples there. Were you thinking something down the lines of the unittest_samples/transform_unit_sample.


Check this


Thanks! I’ll do that!


Hi Shane,

So, I’m currently trying to use NvVideoConverter class in order to flip the image. I also had a look into the video_convert sample.

Now, although I’ve successfully compiled the sample, when I try to use this class on my own code I keep failing to link it to the right library:

undefined reference to `NvVideoConverter::createVideoConverter(char const*, int)

I’m pretty sure I’m doing tremendously idiotic, but I can’t seem to pinpoint the library containing this class. So far I already included all the libraries in the makefile rules for the video_convert sample and right now it looks like this:

LDLIBS=-ljetson-utils -ljetson-inference -lcudart \
		-lpthread -lv4l2 -lEGL -lGLESv2 -lX11 \
        -ldrm -lcuda -lnvinfer -lnvparsers \
        -lnvbuf_utils -lnvjpeg -lnvosd 

Could you let me know which library includes this class?


Hi again,

So… I just realized that the class definition is in the common folder in the jetson_multimedia_api. Sorry about that…

But please…do tell me if I’m not on the right path to flip image after the frame capture.


I am not quite understand your question.
This parameter can rotate the image if your HW can not change to right angle.

Hi Shane,

Sorry for taking so long to answer but I got caught up with work.
Anyway, what I end up by doing was to modify gstCamera class to give me the option to rotate the camera on object creation.

I’ve added a default parameter to Create functions:

static gstCamera* Create( const char* camera=NULL, unsigned short flipMode = 0 );
static gstCamera* Create( uint32_t width, uint32_t height, const char* camera=NULL, unsigned short flipMode = 0);

and created static variable member to receive the value:

static unsigned short flipMode_;

Finally in the buildLaunchStr function I just pass the value of flipMode_ to flipMethod (around line 416):

		const int flipMethod = flipMode_;

There might be a better way to do just pass the flip method while creating gstCamera, but this was the one that worked for me with less applied effort.

Now that I think of… it might be a good idea to overload the Create function where the only thing that is passed. is a launch string… this way you would have full control over the object you’re creating.

Anyway, for now is solved. If there is a better/simpler way to do this, please let me know.


This is the purpose of this patch.

1 Like

Sounds good! :-)