Stereocamera not streaming when I am trying to code using python and opencv on Jetson TK1

Is there a way I could uninstall the Jetpack 3.1 on the host pc ubuntu 14.04 and also Jetson tk1?
Do you know if I could install opencv and the contrib as if I were to do so on a linux platform like ubuntu 14.04?

I want to code on Jetson Tk1 using python and opencv and I tried running my first program to see if my Tara USB 3.0 stereocamera would work but I am getting an error : HIGHGUI ERROR: V4L2: Pixel format of incoming image is unsupported by OpenCV and this was using (Opencv4tegra)

OpenCV expects BGR or GRAY8 format as input (although last versions can support more formats).
What format does your camera provide ?

sudo apt-get install v4l-utils
v4l2-ctl -d /dev/video0 --list-formats

If it cannot provide BGR, you may use gstreamer for converting, but opencv4tegra doesn’t have gstreamer support.

Building opencv from source is not so complicated (just need a disk with a several GB available and about one hour for building).
For building opencv, you may create a build directory (separate from your source directory) and configure using (not verified):

cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/<your_opencv> \
      -D WITH_CUDA=ON -D CUDA_ARCH_BIN="3.2" -D CUDA_ARCH_PTX="" \
      -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON -D ENABLE_NEON=ON \
      -D WITH_LIBV4L=ON -D WITH_GSTREAMER=ON -D BUILD_TESTS=OFF \
      -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF <your_opencv_src_directory>
make
sudo make install

Note that using parallel make, compilers may run out of memory. In such case, just relaunch make.

Once installed, as opencv4tegra is installed in path /usr, be sure to specify <your_opencv> path for compiling/linking your opencv applications and set it in LD_LIBRARY_PATH before running, otherwise opencv4tegra may be used instead.

Hi Honey_Patouceul,
Thank you for replying.I tried the two commands you gave me and this is what I got:

ubuntu@tegra-ubuntu:~$ v4l2-ctl -d/dev/video0 --list-formats
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'Y16 ’
Name : Greyscale 16-bit (Y16 )

Index       : 1
Type        : Video Capture
Pixel Format: ''
Name        : e436eb7d-524f-11ce-9f53-0020af0

This is what I have done so far . I flashed the jetpack 3.1 successfully and got opencv4tegra installed but the camera didn’t work when I tried videostreaming it using python and opencv.The opencv version I get from opencv4tegra is 2.4.13.I then uninstalled opencv4tegra and tried installing opencv using this link:https://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/ but the installation didn’t fully run. When I get to the cmake part i got an error.
Should I reflash the jetpack onto jetson again to install opencv 4 tegra and if so how would i uninstall jetpack 3.1 on the host laptop before I use it again to reflash? Then do I try building opencv from source with GStreamer= on.

I don’t get the part where you said that I would need a disk with several GB available for building opencv from source.Could you elaborate more on that?
Also how would I relaunch cmake if the compilers run out of memory?

Thank you for your help!

You wouldn’t have to uninstall opencv4tegra for installing another opencv version, just be sure to set CMAKE_INSTALL_PREFIX to a diffent path than default ‘/usr’.
Uninstalling opencv4tgera may lead to have an older opencv version installed by apt due to dependancies… You may also reflash.

For building opencv, I meant natively building on TK1, it needs several GBs…Your MMC may not have enough space…Filling your root fs disk on Jetson MMC0 may lead to having problems for booting, so an external disk is safer.
Furthermore, you might want to keep your build for trying other options, thus better to have opencv sources and build on a different disk such as a USB disk or a SD Card.

You just need to run cmake once (unless you see errors from it).

‘make’ can fail because of lack of memory. In such case just relaunch make until it succeeds the whole build.

Thank you. I will try that!!

Would 32 gb SD be good enough?

Size depends on opencv version, but 32 GB should be more than required for any version till 3.4.0.

I’d suggest building last opencv-3.4.0. If it doesn’t support Y16, you may use gstreamer with a pipeline like this one:

cv2.VideoCapture("v4l2src device=/dev/video0 ! video/x-raw, format=(string)GRAY16_LE ! videoconvert ! video/x-raw, format=(string)GRAY8 ! appsink")

This is just an untested proposal, there may be better solutions, though.

Ok Thanks again :) I will definitely try this out and let you know!! I hope it works!