How to capture TX1 Camera with OpenCV?

Hi,

I tried many suggestions in this forum , but none of them was successful.

( all from " https://devtalk.nvidia.com/default/topic/904949/?comment=4857242 " , and more from other threads )

I have no idea what can I do more. Please let me get any other suggestions!
( I’m new on OpenCV and gstreamer! Please explain easy~~ )

< Environment >
TX1 with JetPack 2.3.1 ( OpenCV 2.4 with gstreamer )

< Recent code & output >

int main()
{
    std::cout << "OpenCV Version : " << CV_VERSION << std::endl;
    cv::Mat img;
    cv::namedWindow("EXAMPLE02", 1);

bool useCamera = true;//parser.get<bool>("camera");
    bool update_bg_model = true;

    cv::VideoCapture cap("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)24/1 ! nvvidconv flip-method=2 ! video/x-raw, format=(string)I420 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink");

if (!cap.isOpened()) {
    std::cout << "Cam is not opened!!" << std::endl;
    return -1;
  }

-->>  Always  stuck in 'if' statement.

Hi JaebeomPark,

There are several successful cases to capture TX1 Camera with OpenCV, but it’s not OpenCV 2.4.x.
You will need to install the OpenCV 3.x to work with TX1 onboard camera, please refer to the following thread:
[url]https://devtalk.nvidia.com/default/topic/943129/jetson-tx1/highgui-error-v4l-v4l2-while-opening-camera-with-opencv4tegra-l4t-r24/post/4921383/#4921383[/url]

Regarding OpenCV4Tegra, it’s not well optimized for onboard camera due to pixel format issue, but USB webcam can work.

Thanks