# Camera
## CSI Cameras
* Check if the cameras are being detected.
```bash=
ls /dev/video*
```
* It should return
> Insert Image
* Start rtsp server in ground station
```bash=
docker run --rm -it --network=host aler9/rtsp-simple-server
```
Run camera pipelines in xavier
```bash!
# Camera 1
gst-launch-1.0 nvarguscamerasrc sensor-id=0 ! nvvidconv ! "video/x-raw(memory:NVMM), width=1948, height=1096, format=NV12, framerate=30/1" ! nvv4l2h264enc ! h264parse ! rtspclientsink location=rtsp://10.223.240.0:8554/cam1
```
```bash!
# Camera 2
gst-launch-1.0 nvarguscamerasrc sensor-id=1 ! nvvidconv ! "video/x-raw(memory:NVMM), width=1948, height=1096, format=NV12, framerate=30/1" ! nvv4l2h264enc ! h264parse ! rtspclientsink location=rtsp://10.223.240.0:8554/cam2
```
```bash!
# Camera 3
gst-launch-1.0 nvarguscamerasrc sensor-id=2 ! nvvidconv ! "video/x-raw(memory:NVMM), width=1948, height=1096, format=NV12, framerate=30/1" ! nvv4l2h264enc ! h264parse ! rtspclientsink location=rtsp://10.223.240.0:8554/cam3
```
* Check if all the three feeds are registered in the server
* Run the gst cuda app in the ground station
```bash=
# Use three different terminals for three cameras
cd gst-cuda-app
./docker/docker_run.sh
cd build
./camera1 /Videos/cam1/traffic1
./camera2 /Videos/cam2/traffic2
./camera3 /Videos/cam3/traffic3
```
## ZED Camera
* In both xavier and ground station, go to /usr/local/zed/samples/camera streaming/sender/cpp/
```bash=
cd /usr/local/zed/samples/camera\ streaming/sender/cpp/
```
* Create a build folder and run the following commands
```bash=
mkdir build
cd build
cmake ..
make
```
* Do the same thing in the recevier folder
```bash=
cd /usr/local/zed/samples/camera\ streaming/receiver/cpp/
mkdir build
cd build
cmake ..
make
```
* You will find executables in the build folders of both sender and receiver
* Run the sender in Jetson xavier
```bash=
./ZED_Streaming_Sender 8080
```
* Run the receiver in ground station
```bash=
./ZED_Streaming_Receiver 10.223.240.1:8080
```
## 4K Camera
* Run this in Xavier
```bash!
gst-launch-1.0 v4l2src device=/dev/video1 ! "video/x-raw,format=(string)UYVY,width=(int)1280,height=(int)720" ! nvvidconv ! "video/x-raw(memory:NVMM), format=(string)NV12, width=(int)1280,height=(int)720" ! nvv4l2h264enc ! h264parse ! rtspclientsink location=rtsp://10.223.240.0:8554/4k
```
* Run this in Base Station
```bash!
gst-launch-1.0 rtspsrc location=rtsp://10.223.240.0:8554/4k_stream latency=0 ! decodebin ! videoconvert ! autovideosink
```
## DW Camera
* Nano:
```bash!
gst-launch-1.0 -v v4l2src device=/dev/video1 io-mode=2 ! video/x-h264, width=1920,height=1080 ! h264parse ! queue ! rtph264pay config-interval=10 pt=96 ! udpsink host=10.223.240.0 port=5600 sync=false
```
* Base Station
```bash!
gst-launch-1.0 udpsrc port=5600 ! application/x-rtp ! rtpjitterbuffer ! rtph264depay ! h264parse ! nvh264dec ! glimagesink
```
<b>April 2024 Update</b>
Pipeline in Use
```
gst-launch-1.0 -v udpsrc port=5600 ! application/x-rtp, payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! autovideosink
```
```bash!
gst-launch-1.0 -v v4l2src device=/dev/video1 io-mode=2 ! video/x-h264, width=1920,height=1080 ! h264parse ! rtspclientsink location=rtsp://10.223.240.0:8554/cam1
```
Record and overlay pipeline
```bash!
gst-launch-1.0 -e udpsrc port=5600 ! queue ! application/x-rtp ! rtpjitterbuffer ! rtph264depay ! h264parse ! nvh264dec ! clockoverlay time-format="%D %H:%M:%S" ! tee name=t ! queue ! glimagesink t. ! queue ! nvh264enc ! h264parse ! qtmux ! filesink location=~/Videos/gst-app.mp4
```
Image capture
```bash!
gst-launch-1.0 rtspsrc location="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4" ! decodebin ! jpegenc snapshot=true ! identity error-after=2 ! filesink location=mage.jpeg
```
```bash!
gst-launch-1.0 rtspsrc location="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4" is_live=true ! decodebin ! jpegenc snapshot=TRUE ! filesink location=img.jpg
```
```bash!
gst-launch-1.0 rtspsrc location= rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4 ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! jpegenc ! filesink location=image.jpg
```
```
gst-launch-1.0 rtspsrc location= rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4 ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! jpegenc snapshot=TRUE ! filesink location=image12.jpg
```