-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jetson_Commands.txt
55 lines (50 loc) · 2.49 KB
/
Jetson_Commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
https://github.com/jschmid1/gopro_as_webcam_on_linux
For starting the gopro:
sudo gopro webcam
For streaming output to /dev/video42 :
ffmpeg -nostdin -i 'udp://@0.0.0.0:8554?overrun_nonfatal=1&fifo_size=50000000' -vf setpts=0.9*PTS -flags low_delay -f:v mpegts -fflags nobuffer -vf format=yuv420p -f v4l2 /dev/video42
For launching gstreamer view:
gst-launch-1.0 v4l2src device=/dev/video42 ! video/x-raw, width=1920, height=1080, framerate=30/1 ! xvimagesink
https://www.youtube.com/watch?v=rs4mQcJAjMM
https://github.com/jetsonhacks/camera-caps
For running python script:
python3 camera_caps.py
File "detect.py", line 108
txt_path = str(save_dir / 'labels' / p.stem) + ('' if dataset.mode == 'image' else f'_{frame}') # img.txt
^
SyntaxError: invalid syntax
def take_photo(filename='photo.jpg', quality=0.8, delay=2):
start_time = time.time()
# Display video stream
js = Javascript('''
(async () => {
const video = document.createElement('video');
video.style.display = 'block';
const stream = await navigator.mediaDevices.getUserMedia({video: true});
document.body.appendChild(video);
video.srcObject = stream;
await video.play();
// Wait for the video to start streaming
await new Promise(resolve => video.onplaying = resolve);
// Capture a frame after delay
await new Promise(resolve => setTimeout(resolve, 1000));
const canvas = document.createElement('canvas');
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0);
stream.getVideoTracks()[0].stop();
// Convert the canvas to base64 encoded image
const imgData = canvas.toDataURL('image/jpeg', 0.8);
google.colab.kernel.invokeFunction('notebook.take_photo', [imgData], {});
})();
''')
display(js)
# Callback function to receive image data
def take_photo_callback(imgData):
binary = base64.b64decode(imgData.split(',')[1])
img = Image.open(io.BytesIO(binary))
img.save(filename, 'JPEG')
end_time = time.time()
print(f'Photo taken and saved as {filename}. Time taken: {end_time - start_time:.2f} seconds.')
# Register the callback function
output.register_callback('notebook.take_photo', take_photo_callback)