Note that the input-flip argument currently only applies to MIPI CSI cameras, because that GStreamer pipeline has access to the nvvidconv
element that can do the rotations. If you needed that for V4L2 camera too, you may be able to add a similar nvvidconv element to the V4L2 version of the pipeline. That stuff is all done around here in the code:
if( mOptions.resource.protocol == "csi" )
{
#if NV_TENSORRT_MAJOR > 4
// on newer JetPack's, it's common for CSI camera to need flipped
// so here we reverse FLIP_NONE with FLIP_ROTATE_180
if( mOptions.flipMethod == videoOptions::FLIP_NONE )
mOptions.flipMethod = videoOptions::FLIP_ROTATE_180;
else if( mOptions.flipMethod == videoOptions::FLIP_ROTATE_180 )
mOptions.flipMethod = videoOptions::FLIP_NONE;
ss << "nvarguscamerasrc sensor-id=" << mOptions.resource.port << " ! video/x-raw(memory:NVMM), width=(int)" << GetWidth() << ", height=(int)" << GetHeight() << ", framerate=" << (int)mOptions.frameRate << "/1, format=(string)NV12 ! nvvidconv flip-method=" << mOptions.flipMethod << " ! ";
#else
// older JetPack versions use nvcamerasrc element instead of nvarguscamerasrc
ss << "nvcamerasrc fpsRange=\"" << (int)mOptions.frameRate << " " << (int)mOptions.frameRate << "\" ! video/x-raw(memory:NVMM), width=(int)" << GetWidth() << ", height=(int)" << GetHeight() << ", format=(string)NV12 ! nvvidconv flip-method=" << mOptions.flipMethod << " ! "; //'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1' ! ";
#endif
ss << "video/x-raw ! appsink name=mysink";
}
else
{
ss << "v4l2src device=" << mOptions.resource.location << " ! ";
In terms of adding it as a ROS parameter, you would add it around here in the video_source node:
int video_width = video_options.width;
int video_height = video_options.height;
ROS_DECLARE_PARAMETER("resource", resource_str);
ROS_DECLARE_PARAMETER("codec", codec_str);
ROS_DECLARE_PARAMETER("width", video_width);
ROS_DECLARE_PARAMETER("height", video_height);
ROS_DECLARE_PARAMETER("framerate", video_options.frameRate);
ROS_DECLARE_PARAMETER("loop", video_options.loop);
/*
* retrieve parameters
*/
ROS_GET_PARAMETER("resource", resource_str);
ROS_GET_PARAMETER("codec", codec_str);
ROS_GET_PARAMETER("width", video_width);
ROS_GET_PARAMETER("height", video_height);
ROS_GET_PARAMETER("framerate", video_options.frameRate);
ROS_GET_PARAMETER("loop", video_options.loop);
You would probably want to add something like this:
std::string flip_str;
ROS_DECLARE_PARAMETER("flip", flip_str);
ROS_GET_PARAMETER("flip", flip_str);
if( flip_str.size() != 0 )
video_options.flipMethod = videoOptions::FlipMethodFromStr(flipStr.c_str());
video_options.flipMethod =