Is There a parameter for enable/disable the TX2 on-board camera?

v4l2-ctl -d /dev/video0
and then?

Not sure what you want to do…

If you want to disable the onboard camera for saving power I cannot give good advices.

If you just want to use the onboard camera:

Note that sensor OV5693 is sending bayer frames in several resolutions, mainly:
1. 2592 x 1944 @30fps (4:3)
2. 2592 x 1458 @30fps (16:9)
3. 1280 x 720 @120fps (16:9)
4. 1920 x 1080 @30fps (16:9)

There are several ways for using it:

  • With gstreamer : use plugin nvcamerasrc as video source. This plugin will autoconfigure the camera (first frames may be dark), debayer frames, scale if requested, and provide as I420 or NV12 format into NVMM memory (for ISP or GPU access). For example
gst-launch-1.0 nvcamerasrc ! 'video/x-raw(memory:NVMM), format=I420, width=640, height=480, framerate=30/1' ! nvvidconv ! 'video/x-raw' ! xvimagesink

This pipeline uses plugin nvvidconv for sending into cpu memory to be used by video sink plugin xvimagesink. There are other video sink plugins you might try such as nveglglessink or nvoverlaysink. Searching this forum you can find many examples. AFAIK, you cannot use v4l2src plugin, because this plugin only accepts 8 bits bayer frames and currently only 10bits bayer frames can be received from CSI with onboard camera, although it may work with USB cameras sending 8 bits rggb frames.

  • With V4L2 API. This is not the easy way. If you want to have full control from bayer frames you may get it but I suspect some (maybe a lot) extra work. For a quick look at what you can get, I would suggest to install qv4l2 and v4l-utils:
sudo apt-get install qv4l2 v4l-utils

and try first qv4l2. Note that you have to select 10 bits modes (BG10 is a bit yellow, while RG10 is very blue). For resolution use 720p or 1080p.
Start capture, colors may be weird, you will have to go to camera control tabfolder and adjust the gain manually for getting it.

Note also the control just below gain: the bypass mode should be 0. If you activate it, then it may interfere with nvcamera-deamon that is used by nvcamerasrc gstreamer plugin and would lead to failures. Note that nvcamera-deamon activates it, so be sure to deactivate it for using V4L interface after nvcamera-deamon is no longer used.

If you want to get frames from command line, you may use something like:

v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=BG10 --stream-mmap -d /dev/video0 --set-ctrl bypass_mode=0

or if you want save 300 first frames to file:

v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=BG10 --stream-mmap -d /dev/video0 --set-ctrl bypass_mode=0 --stream-count=300 --stream-to=ov5693.raw

Note the latter command with 300 frames would use more than 600MB on your disk.

  • With tegra multimedia API. Have a look to samples in your /home/nvidia directory.

Thanks for the quick answer!
I am also looking for its parameters list - main one i need is the autofocus enable/disable option if exists.

I had some issues when connecting a second camera(external HD cam) that worked really slow(even when it was the only USB3 connected to the board

Not 100% sure, but I think OV5693 is a fixed focus sensor.
[EDIT: Not 100% sure again, but looking at

cat /sys/firmware/devicetree/base/tegra-camera-platform/modules/module0/drivernode0/devname 
ov5693 2-0036
cat /sys/firmware/devicetree/base/tegra-camera-platform/modules/module0/drivernode1/devname 
<b>lc898212</b> 2-0072

there may be an autofocus chip.]

For other options, you can get the list:

  • with gstreamer:
gst-inspect-1.0 nvcamerasrc
  • with v4l2:
v4l2-ctl -l

If it gets slow, you may try to boost your jetson:

sudo nvpmodel -m0
sudo /home/nvidia/jetson_clocks.sh

how to convert the ov5693.raw to mp4 or to something that can be displayed?

Hi Andrey,

I’ve just seen your question now, sorry for missing it.

You have to convert from 10 bits to 8 bits. 10 bits or 12 bits are in fact recorded into 16 bits.
So just need to read two bytes, ignore the 2 LSb and store as 8 bits.
Here is a sample code for doing this from stdin to stdout:

#include <stdio.h>

int main (int argc, char** argv) 
{
        unsigned short sbuf[2048];
        unsigned char cbuf[2048];
        unsigned int readItems;

        while ((readItems = fread(sbuf, 2, 2048, stdin)) > 0) {
                for (unsigned int curItem=0; curItem < readItems; curItem++)
                        cbuf[curItem] = sbuf[curItem]/4;
                fwrite(cbuf, 1, readItems, stdout);
        }

        return 0;
}

Just build such as:

gcc -o bayer10_to_8 bayer10_to_8.c

So, let’s make a 3s capture in BG10 mode, 1280x720 @ 120fps:

v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=BG10 --stream-mmap -d /dev/video0 --set-ctrl bypass_mode=0 --stream-count=360 --stream-to=ov5693.BG10

Then convert into 8 bits bggr (file size will be half):

cat ov5693.BG10 | ./bayer10_to_8 > ov5693.bggr

Now you can play it with gstreamer:

gst-launch-1.0 filesrc location=ov5693.bggr blocksize=921600 ! 'video/x-bayer, width=1280, height=720, framerate=120/1, format=bggr' ! bayer2rgb ! videoconvert ! xvimagesink