Use local video as camera input

Hi, I wanna test my code with camera input. But with the limitation of TX2 and equipment I cannot bring my device to test outside. Using a camera to take pictures on a computer monitor is very ineffective. Is there any method to using Local Video as Virtual Input for Camera? Thanks !!

I’m not sure what you mean…are you saying that needing a display while using your camera software is the issue since you can’t take the display outside where testing is needed? If so, then you probably need to install some sort of virtual desktop software.

Virtual desktop servers look like an ordinary X server to the system, but virtual displays do not require a physical monitor (often this is used to view a Linux desktop from a remote system which isn’t Linux, e.g., a Windows virtual desktop client program might be used to view and interact with a remote Linux system…but everything still runs on Linux). I don’t have specific recommendations if this is the case, but there are some older threads on the topic which might be of interest (assuming this is what you were asking):
https://devtalk.nvidia.com/default/topic/828974/embedded-systems/-howto-install-virtualgl-and-turbovnc-to-jetson-tk1/
https://devtalk.nvidia.com/default/topic/1021344/jetson-tx2/vnc-setup-question/

VirtualGL is the one I think I heard about working.

If you want to emulate a camera from a video file, you may try v4l2loopback:

sudo apt-get install v4l2loopback-dkms v4l2loopback-utils

Then:

sudo modprobe v4l2loopback

should make a /dev/videoX virtual device (for example, if you only have /dev/video0 for onboard cam, then a new /dev/video1 would appear).

You would then feed this virtual node with data (for example a gstreamer pipeline may read the file, convert to RGB and feed this node with plugin v4l2sink). Then you should be able to use this /dev/video1 node as a RGB camera.

You may also read this topic.

@linuxdev Thanks for your advice. What I mean is I need a softcamera that just like v4l2loopback or avld. But I have tried these two methods.It seems is not workbale.

UPDATE## SOLVED
Hi, Honey_Patouceul. I have tried the v4l2loopback throght .tar and apt-get. It is both unsuccessful. There are following errors:

For installing from a .tar file:

Building v4l2-loopback driver…
make -C /lib/modules/uname -r/build M=/home/nvidia/Downloads/v4l2loopback-master modules
make[1]: Entering directory ‘/usr/src/linux-headers-4.4.38-tegra’
CC [M] /home/nvidia/Downloads/v4l2loopback-master/v4l2loopback.o
scripts/basic/fixdep: 1: scripts/basic/fixdep: Syntax error: “(” unexpected
scripts/Makefile.build:267: recipe for target ‘/home/nvidia/Downloads/v4l2loopback-master/v4l2loopback.o’ failed
make[2]: *** [/home/nvidia/Downloads/v4l2loopback-master/v4l2loopback.o] Error 2
Makefile:1414: recipe for target ‘module/home/nvidia/Downloads/v4l2loopback-master’ failed
make[1]: *** [module/home/nvidia/Downloads/v4l2loopback-master] Error 2
make[1]: Leaving directory ‘/usr/src/linux-headers-4.4.38-tegra’
Makefile:42: recipe for target ‘v4l2loopback.ko’ failed
make: *** [v4l2loopback.ko] Error 2

For install from apt-get( e.g. your advice):

First Installation: checking all kernels…
dpkg: warning: version ‘-’ has bad syntax: version number does not start with digit
It is likely that 4.4.38-tegra belongs to a chroot’s host
Building initial module for 4.4.38-tegra
ERROR (dkms apport): kernel package linux-headers-4.4.38-tegra is not supported
Error! Bad return status for module build on kernel: 4.4.38-tegra (aarch64)
Consult /var/lib/dkms/v4l2loopback/0.9.1/build/make.log for more information.
Setting up v4l2loopback-utils (0.9.1-4ubuntu0.1) …

which seems like a problem of kernel unsuported I guess. The version of my TX2 is Jetpack3.3. I cannot find a solution from google.
I will read the topic you mentioned. Hope find a good solution!Thanks!

Hi. I have solved the problem! Thanks!