Notifications
Clear all

Camera stream  

Page 1 / 2
  RSS
BadPixel
(@badpixel)
Member
Camera stream

Hi! I couldn't find anything about this, but my apologies if this has been answered before.

I setup Link and Connect yesterday and they're running smoothly. One thing that bugs me though is that the camera feed (I'm using a Pi cam) only sends snapshots. Isn't there a way for getting a live feed, as in Octoprint?

Posted : 15/09/2023 9:26 am
You liked
Tojik
(@tojik)
Member Moderator
RE: Camera stream

Hi, unfortunately the most we can do is one snapshot per 10s

Posted : 15/09/2023 9:40 am
Kris
 Kris
(@kris-5)
Active Member
RE: Camera stream

Hey Tojik,

Is there a reason for this? For our internal dashboard I'd love to be able to capture the livestreams from PrusaLink. Could you go maybe indulge me in how you get the camera streams and how one could take the streams / snapshots being thrown to Connect and divert it somewhere else?

Posted : 04/10/2023 1:18 pm
Tojik
(@tojik)
Member Moderator
RE:

Hi, if I knew how to get 1080p30 on a Zero W while printing circles. I would probably just put it in PrusaLink. The whole reason we don't have this is that cameras are hard.

You can probably find guides on how to stream video from a raspberry pi locally and run that alongside link pretty painlessly? Idk tho

Posted : 04/10/2023 1:33 pm
Kris
 Kris
(@kris-5)
Active Member
RE: Camera stream

Yeah that's what I figured next, if it wasn't possible to hijack the PrusaLink/Connect stream I was gonna look into a pi stream next.
How would that work for the MK3.9's / MK4s by the way? We're upgrading our 3's to 3.9's from January, which means we shouldn't need to use the raspberry's anymore, but we'll also in that case lose the USB-A slots from the Pi's. Do you happen to know anything about the 4 supporting usb cameras?

Posted : 04/10/2023 1:45 pm
Hello
(@hello)
Noble Member
RE: Camera stream

I'm in the same boat wanting live stream I'm wondering how hard it would be to recode prusalink or like you say intercept prusalink signal and send constant video stream

Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models

Posted : 04/10/2023 7:42 pm
Tojik
(@tojik)
Member Moderator
RE: Camera stream

Go look, the entire thing sits on the internet free of charge. If you make it stream video, just publish the code so we can have it too

Posted : 04/10/2023 8:22 pm
Kris liked
Hello
(@hello)
Noble Member
RE:

 

Posted by: @tojik

Go look, the entire thing sits on the internet free of charge. If you make it stream video, just publish the code so we can have it too

Yeah I've been looking into it I'm away on holiday for 2 weeks so not going to be able to do anything till I'm back 

Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models

Posted : 04/10/2023 8:49 pm
Hello
(@hello)
Noble Member
RE: Camera stream

@tojik could you tell me in what file sets the time it takes photo and sends them / displays theme 

Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models

Posted : 04/10/2023 10:01 pm
Tojik
(@tojik)
Member Moderator
RE: Camera stream

Yea, you can shorten the timer, that doesn't make it a camera video stream. That just makes it take photos faster. You would then need the web to get the shots faster making an unholy amount of http requests. That's why it's called a video stream. It streams the data, not getting each frame separately. There is just one pipe to throw data into as they are being captured with buffers on both ends. That's not implemented in PrusaLink, I would be very surprised if someone made that in their free time just to have MK3 video without just using mjpg-streamer like OctoPrint

It's in Prusa-Connect-SDK-Printer  /prusa/connect/printer/const.py line 236 - TRIGGER_SCHEME_TO_SECONDS

Another constant that influences how fast is the web getting the images is in Prusa-Link /prusa/link/const.py line 97 - TIME_FOR_SNAPSHOT

Posted : 05/10/2023 9:30 am
Hello
(@hello)
Noble Member
RE: Camera stream

 

Posted by: @tojik

Yea, you can shorten the timer, that doesn't make it a camera video stream. That just makes it take photos faster. You would then need the web to get the shots faster making an unholy amount of http requests. That's why it's called a video stream. It streams the data, not getting each frame separately. There is just one pipe to throw data into as they are being captured with buffers on both ends. That's not implemented in PrusaLink, I would be very surprised if someone made that in their free time just to have MK3 video without just using mjpg-streamer like OctoPrint

It's in Prusa-Connect-SDK-Printer  /prusa/connect/printer/const.py line 236 - TRIGGER_SCHEME_TO_SECONDS

Another constant that influences how fast is the web getting the images is in Prusa-Link /prusa/link/const.py line 97 - TIME_FOR_SNAPSHOT

Also could you tell me where the code is that it gets the link of camera

Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models

Posted : 05/10/2023 6:33 pm
Tojik
(@tojik)
Member Moderator
RE:

> Also could you tell me where the code is that it gets the link of camera
What? What link? If you want to know what api endpoint to call to get the most up to date image, read the api docs in Prusa-Link-Web repo, then using the path, you can find the endpoint in link. But what is a link of camera i have no idea.

I am aggravated. Please, if you're going to "recode prusalink" to stream video, then ask me how to do basic stuff like shorten the timer to get more snapshots, at least take the time to attempt to form a proper sentence. If you want me to do the work for you, it's rude to me that you won't even invest the time to ask properly.

Thank you

Posted : 09/10/2023 9:33 am
Zappes and Kris liked
Hello
(@hello)
Noble Member
RE: Camera stream

I found it all just carnt do anything till I get back to my pi

Posted by: @tojik

> Also could you tell me where the code is that it gets the link of camera
What? What link? If you want to know what api endpoint to call to get the most up to date image, read the api docs in Prusa-Link-Web repo, then using the path, you can find the endpoint in link. But what is a link of camera i have no idea.

I am aggravated. Please, if you're going to "recode prusalink" to stream video, then ask me how to do basic stuff like shorten the timer to get more snapshots, at least take the time to attempt to form a proper sentence. If you want me to do the work for you, it's rude to me that you won't even invest the time to ask properly.

Thank you 

Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models

Posted : 09/10/2023 7:35 pm
luma
 luma
(@luma)
Member
RE: Camera stream

I've been working on a solution like this and it works well enough on a 3B to run Prusa-Link on one printer while running USB camera streams for two 1080p cameras.  One challenge I keep running into is that Prusa-Link is "greedy" with camera devices and will attempt to grab control over any new camera device it finds.  This creates all sorts of problems for anything else running on the system, eg: a camera streaming service cannot restart the service to change settings because prusa-link will grab the camera during the restart.  It'd be great if there was a way to disable that behavior, or even disabling cameras all together such that external camera solutions could better integrate on the same pi.

Posted : 10/10/2023 12:34 am
Hello
(@hello)
Noble Member
RE: Camera stream

 

Posted by: @luma

I've been working on a solution like this and it works well enough on a 3B to run Prusa-Link on one printer while running USB camera streams for two 1080p cameras.  One challenge I keep running into is that Prusa-Link is "greedy" with camera devices and will attempt to grab control over any new camera device it finds.  This creates all sorts of problems for anything else running on the system, eg: a camera streaming service cannot restart the service to change settings because prusa-link will grab the camera during the restart.  It'd be great if there was a way to disable that behavior, or even disabling cameras all together such that external camera solutions could better integrate on the same pi.

Do you have the code or a github

Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models

Posted : 10/10/2023 1:05 am
_KaszpiR_
(@_kaszpir_)
Honorable Member
RE: Camera stream

@luma you could create new user/group for prusalink, and that user is not added to the users wich allow accessing camera devices.

If prusalink still needs camera ( for example if it would crash without it, I don't know ) then you could create new dummy video device and change ownership or permissions to it so it would be accessible for that user/group.

See my GitHub and printables.com for some 3d stuff that you may like.

Posted : 10/10/2023 7:13 am
luma liked
Tojik
(@tojik)
Member Moderator
RE: Camera stream

Hi,
here, a kinda bad reference to the configuration file of prusalink
https://github.com/prusa3d/Prusa-Link/blob/master/prusa/link/data/prusalink.ini

Make a file in /etc/prusalink/ named prusalink.ini
Put this inside

[cameras]
auto_detect=False

Now it's not greedy anymore
Profit

Posted : 10/10/2023 10:04 am
Zappes, luma and _KaszpiR_ liked
luma
 luma
(@luma)
Member
RE:
Posted by: @tojik

Make a file in /etc/prusalink/ named prusalink.ini

Put this inside

[cameras]
auto_detect=False

Now it's not greedy anymore
Profit

This is exactly what I needed, thanks @tojik!


Posted by: @hello

 Do you have the code or a github

Nothing quite so fancy yet but the general concept is simple if you follow a couple rules:

  • Stream in camera-native format, do no video processing at all on the pi
  • Only send out a maximum of one stream per camera, ideally to a video server

For example, most Logitech webcams will stream MJPEG, so install MJPEG streamer or whatever else you like and make sure that you are not doing any transcoding.  Then, setup a video server somewhere that's not the pi, have it ingest your pi camera stream, and then point all consumers at that video server (never at the pi).  This way, if you have 3 web browser windows all with the video stream open, the load on the pi never changes, it's always just sending out a single copy of the webcam stream in it's native format with no processing to the video server and your web pages are pulling the stream from the video server.

In my setup I'm using go2rtc for the video proxy, it's a high performance solution to do what I suggest above, ingest a video stream and then supply it to multiple consumers on-demand. It utilizes very little resources when not actively streaming.

That'll get you a camera stream that you can use as needed, but it won't appear in the Prusa-Link web page and it also won't appear in Prusa Connect cloud.  I don't have a solution for Prusa-Link quite yet (trying to get it to share a device via v4l2loopback hasn't worked) but there is a way to feed camera stills into Prusa Connect manually.  I'm doing this in Home Assistant and it fires off a bash script every 10 seconds if a print job is currently active:

token=[prusa-connect token] ;
fingerprint=[prusa-connect fingerprint];
ha_url=[home assistant url];
prusaconnect_cameras=[home assistant long lived token];
ha_camera_entity=[home assisant camera entity name];
temp_file=$(mktemp -t "${ha_camera_entity}-XXXXXX") ;
curl -X GET -H "Authorization: Bearer ${prusaconnect_cameras}" -H "Content-Type: application/json" -o ${temp_file} ${ha_url}/api/camera_proxy/${ha_camera_entity} ;
curl -X PUT -H "token: $token" -H "fingerprint: $fingerprint" -H "Content-Type: image/jpg" --data-binary @${temp_file}  https://connect.prusa3d.com/c/snapshot  ;
rm $temp_file
Posted : 10/10/2023 2:50 pm
Tojik and Zappes liked
aserwatuk
(@aserwatuk)
Member
RE: Camera stream

I've been doing some research on this in a similar vein.

I want to find a way to add spaghetti detection to Prusa Connect.
The only thought I had that seemed feasible was to have something like Obico.io or Octoeverywhere running "standalone". Just monitoring the camera feed. And then, using the Prusalink or Prusa Connect APIs to issue pause and/or stop commands.

BUT... none of the solutions have a standalone. So... wasn't sure where to go next with it. But, getting the camera feed going was possibly step 1.
I was going to try setting up a virtual printer in Octoprint but using the camera feed and somehow "fudge" the destination for the pause/stop commands.

Posted : 25/10/2023 8:45 pm
Hello
(@hello)
Noble Member
RE: Camera stream

Hmm this would take alot to implement I reckon Octoeverywhere monitoring in the background without octoprint would be a good start I reckon

Posted by: @aserwatuk

I've been doing some research on this in a similar vein.

I want to find a way to add spaghetti detection to Prusa Connect.
The only thought I had that seemed feasible was to have something like Obico.io or Octoeverywhere running "standalone". Just monitoring the camera feed. And then, using the Prusalink or Prusa Connect APIs to issue pause and/or stop commands.

BUT... none of the solutions have a standalone. So... wasn't sure where to go next with it. But, getting the camera feed going was possibly step 1.
I was going to try setting up a virtual printer in Octoprint but using the camera feed and somehow "fudge" the destination for the pause/stop 

Please help me out by downloading a model it's free and easy but really helps me out https://www.printables.com/@Hello_474427/models

Posted : 26/10/2023 2:37 am
Page 1 / 2
Share: