Home        Store        Learn        Blog

Second Camera Auto Run

Hi,

I have 2 camera on my ROV. When rov runs, I want the code I prepared for the second camera to return but it must be a .sh file.

I tried with crontab but it did not work when I tried with crontab. I did it with my raspberry pi 4 but when I do same things with raspberry pi 3 it does not work. (companion version: 0.0.28-18-g690ba0c . I have to use this version because it is the only version that works with DVL)

Thanks.

Hi @ugurdemirezen,

Without information on the camera you’re using or the code you’ve written it’s difficult to help.

By “when rov runs” do you mean when it gets powered on, or when the vehicle is armed?

Is this a limitation on your end? The .companion.rc file that’s used for setup when the ROV is turned on doesn’t have any file type requirements (it runs various python and shell files without issues).

What is the “it” that you did? Companion 0 isn’t expected to run on Raspberry Pi 4 by default, so I’m unsure how you tried something with Companion 0 that apparently worked on Raspberry Pi 4 but not Raspberry Pi 3.


Assuming your extra camera has a H264-encoded output option, you might want to try the approach I detailed here, which allows setting up multiple streams with only relatively minor modifications to the existing Companion video streaming code.

Yes I mean when it gets powered on second camera will start streaming. I am using a usb camera for testing.

I am using this code :

gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,width=640,height=480,framerate=\(fraction\)30/1 ! videoconvert ! jpegenc ! udpsink host=192.168.2.1 port=5001

when I run it in the terminal it is working. But I want it to work when the robot gets powered on.

‘libgstreamer-1.0.so.0’ is missing so it is not working i guess. How can i add this library ? I am trying

$sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

this code. But output is :

E: Unable to locate package libgstreamer0.10-dev
E: Couldn't find any package by regex 'libgstreamer0.10-dev'
E: Unable to locate package libgstreamer-plugins-base0.10-dev
E: Couldn't find any package by regex 'libgstreamer-plugins-base0.10-dev'

Can you help me about that ?

Probably the best way to do that is to create a shell script that runs that command, and run that shell script in its own screen session from the .companion.rc file. You could also modify scripts/start_video.sh to be agnostic of stream type (i.e. allow it to take in video/x-h264 or video/x-raw as part of the settings), in which case you’d be able to use the rest of the approach I linked to in my previous comment.

gstreamer 1.0 (one-point-zero) and 0.10 (zero-point-ten) are not the same. You mentioned that it was working before from the terminal - what changed? I don’t expect you should need to install any extra dependencies/libraries, and it’s possible that doing so may cause issues with the normal video streaming functionality.

I tried it but it did not work. But it should not be that difficult.

I tried this. and the output was “libgstreamer-1.0.so.0” is missing.

It is not about the streaming. There should be a method that allows any program to run automatically when reboot.( like crontab)

That webpage is from 2012, and also doesn’t mention gstreamer anywhere, so I’m not sure how you could’ve ended up with that error.

As mentioned, that’s what we use .companion.rc for.

If for some reason you can’t or don’t want to use that, then try one of these general alternatives. I would note that our normal video streaming functionality is started from .companion.rc, so I’d expect that’s a safer bet since you know any required components should be loaded/available at that point in the booting process.