Jetson Nano CSI camera

I am trying to add a CSI camera stream to the watchman agent on Jetpack 4.2.1 using the Nano developer board. I am able to stream the camera using Nvidia accelerated gstreamer using the following:

gst-launch-1.0 nvarguscamerasrc ! ‘video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12’ ! nvvidconv flip-method=0 ! ‘video/x-raw,width=960, height=616’ ! nvvidconv ! nvegltransform ! nveglglessink -e

Reading the instructions from openalpr I have done the following:

  1. Edit /etc/openalpr/stream.d/[cameraname].conf
  2. Add gstreamer_format = [your custom gstreamer pipeline]
  3. Remove the “autovideosink” and replace it with “appsink name=sink max-buffers=5”
  4. Make sure you do not include the “gst-launch-1.0” command at the beginning.

I use the following in /etc/openalpr/stream.d/test.conf without success:

gstreamer_format = nvarguscamerasrc ! ‘video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12’ ! nvvidconv flip-method=0 ! ‘video/x-raw,width=960, height=616’ ! nvvidconv ! nvegltransform ! nveglglessink -e appsink name=sink max-buffers=5

I believe the last sink part is the issue, I have tried multiple combinations of settings with no success.

Any help greatly appreciated :slight_smile:

For anyone with the same problem or using a CSI camera on a Jetson Nano board, this is how we got it to work.

  1. Edit /etc/openalpr/stream.d/[cameraname].conf
  2. Add stream = blank
  3. Add camera_id = 123
  4. Add gstreamer_format = [your custom gstreamer pipeline]

My gstreamer format was:
nvarguscamerasrc ! video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12 ! nvvidconv flip-method=0 ! video/x-raw,width=960, height=616 ! nvvidconv ! video/x-raw ! videoconvert ! video/x-raw,format=(string)BGR ! videoconvert ! appsink name=sink max-buffers=5

Thanks to Matt worked out we need it to go to CPU memory, remove all ’ and add the stream and camera id or else the agent skips it.

Hi Gabe. I’ve also been having issues with getting a CSI camera running on my Nano.

My first problem is that I don’t have a config file (or any files) located at /etc/openalpr/stream.d/. The directory exists but [cameraname].conf does not.

Any Ideas?

Ah, so I think you made a .conf file that looks like this:

stream = “”
camera_id = 123
gstreamer_format = nvarguscamerasrc ! video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12 ! nvvidconv flip-method=0 ! video/x-raw,width=960, height=616 ! nvvidconv ! video/x-raw ! videoconvert ! video/x-raw,format=(string)BGR ! videoconvert ! appsink name=sink max-buffers=5

I’m not sure that this works for my Nano as when I’m on the homepage of the GUI, all I get is the camera name on the left and the classic “Waiting for video” screen with a black background.

What camera are you using? In this case it was the raspberry pi v2 I believe. Give your stream a name, anything should be fine.

To get more debug info try:

sudo su
service openalpr-daemon stop
export GST_DEBUG=2
alprd -f

I’m using a MX219-77 camera that has a Sony IMX219 sensor according to the ebay listing.
I believe it might have something to do with the pipeline I’m using. I’ve copied this one from JetsonHacks:

nvarguscamerasrc sensor_mode=0 ! 'video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12' ! nvvidconv flip-method=0 ! 'video/x-raw,width=960, height=616' ! nvvidconv ! nvegltransform ! nveglglessink

The link to the above pipeline was taken from here: https://github.com/JetsonHacksNano/CSI-Camera

These debug commands…

sudo su
service openalpr-daemon stop
export GST_DEBUG=2
alprd -f

…produce the following output:

INFO    Running OpenALPR daemon in the foreground.
INFO    Using: /etc/openalpr/alprd.conf for daemon configuration
INFO    Using: /usr/share/openalpr/config/alprd.defaults.conf for daemon defaults
INFO    Using: /var/lib/openalpr/plateimages/ for storing valid plate images
INFO    Using: 2 analysis threads
INFO    Using: 6 upload threads
INFO    Using: 10 frames for each video buffer
INFO    Image Archive: Initialized archive.  Path: /var/lib/openalpr/plateimages/ - Maximum of 8 chunks at 500 MB per chunk
INFO    Image Archive: Deleting oldest chunks.  Current archive size (before delete) is 0 / 9 chunks
INFO    Image Archive: Disk free space: 16180596736 / 31331373056
INFO    Image Archive watching: /var/lib/openalpr/plateimages/image_db
DEBUG   upload thread 547457322544 initialized.
INFO    Connecting to Beanstalk
DEBUG   Starting write thread: 1
DEBUG   put job id: 11
DEBUG   upload thread 547440537136 initialized.
DEBUG   upload thread 547432144432 initialized.
DEBUG   upload thread 547448929840 initialized.
DEBUG   upload thread 547423751728 initialized.
INFO    Checking local license.  Status: Use_Online
DEBUG   upload thread 547339890224 initialized.
DEBUG   Writing heartbeat
DEBUG   Upload response: Data accepted for processing
DEBUG   Job: 11 successfully uploaded in 1722.58ms. on thread 547457322544
INFO    Successfully refreshed online license
DEBUG   Saving license key to /etc/openalpr/onlinelicense.conf
INFO    License refresh complete (0 0).  Next refresh in 120 minutes
INFO    License check complete.  License is valid for this system.
INFO    Registering camera  123
INFO    Opening stream: streeeeem
INFO    GPU Acceleration detected
INFO    Initializing analysis thread # 1 on GPU 0
INFO    Initializing group processing thread # 1
INFO    country: us -- config file: /etc/openalpr/openalpr.conf
INFO    Group processing thread initialized
0:00:00.035959130 15913   0x5592b36a10 WARN                  ladspa gstladspa.c:507:plugin_init:<plugin4> no LADSPA plugins found, check LADSPA_PATH
DEBUG   camera        123: video fps:     0 motion:     0% rec. fps:     -
INFO    Checking for incompatible GStreamer plugins
INFO    Removing plugin nvvideo4linux2 from GStreamer Registry
INFO    Removing plugin nvjpeg from GStreamer Registry
INFO    Removing plugin omx from GStreamer Registry
DEBUG   Using custom stream decoding nvarguscamerasrc ! video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12 ! nvvidconv flip-method=0 ! video/x-raw,width=960, height=616 ! nvvidconv ! nvegltransform ! nveglglessink
INFO    Video stream connecting... (streeeeem)
INFO    Video Stream Starting: streeeeem
DEBUG   Video Stream Pipeline: nvarguscamerasrc ! video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12 ! nvvidconv flip-method=0 ! video/x-raw,width=960, height=616 ! nvvidconv ! nvegltransform ! nveglglessink

** (alprd:15865): CRITICAL **: 15:01:57.352: gst_app_sink_set_caps: assertion 'GST_IS_APP_SINK (appsink)' failed

** (alprd:15865): CRITICAL **: 15:01:57.352: gst_app_sink_set_emit_signals: assertion 'GST_IS_APP_SINK (appsink)' failed

** (alprd:15865): CRITICAL **: 15:01:57.352: gst_app_sink_set_drop: assertion 'GST_IS_APP_SINK (appsink)' failed

** (alprd:15865): CRITICAL **: 15:01:57.352: gst_app_sink_set_max_buffers: assertion 'GST_IS_APP_SINK (appsink)' failed

** (alprd:15865): CRITICAL **: 15:01:57.352: gst_app_sink_set_callbacks: assertion 'GST_IS_APP_SINK (appsink)' failed

Using winsys: x11 
INFO    Using normal priority for gstreamer thread 545028087344
INFO    Video state change 2
INFO    Video Stream Start complete
INFO    Video stream initializing (streeeeem)
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:543 Failed to create CaptureSession
INFO    Video Stream Unloading: streeeeem
INFO    Unloading video recorder sink
INFO    Video Stream Unloaded: streeeeem
INFO    Video Stream Starting: streeeeem
DEBUG   Video Stream Pipeline: nvarguscamerasrc ! video/x-raw(memory:NVMM),width=3820, height=2464, framerate=21/1, format=NV12 ! nvvidconv flip-method=0 ! video/x-raw,width=960, height=616 ! nvvidconv ! nvegltransform ! nveglglessink
DEBUG   Video Stream delaying stream restart for minimum of 2000 milliseconds
DEBUG   camera        123: video fps:     0 motion:     0% rec. fps:     -

Update: I realized that it was just a gstreamer pipeline issue. I tweaked my pipeline until it worked.
Thanks Gabe and OpenALPR docs.