AndreasReitberger / KlipperRestApiSharp

A C# based library to communicate with a klipper using Moonraker as WebApi base.
https://andreas-reitberger.de/datenbanken-softwareloesungen/nugets/klipperrestapisharp/
Apache License 2.0
14 stars 2 forks source link

App doesn’t connect to webcam #4

Closed adrianocr closed 2 years ago

adrianocr commented 2 years ago

If I load up fluidd in a browser or use another iOS app like mobileraker the webcam shows correctly. But on RC klipper 3D the webcam doesn’t load. It connects to the server and printer, and everything else works. But the webcam doesn’t

AndreasReitberger commented 2 years ago

Thank you very much for your bug report. I'll check it with fluiddPi and release a fix. Do you see any error log in the Event Manager page? If so, please share it here.

Best, Andreas

AndreasReitberger commented 2 years ago

Hi @adrianocr I just switched my print server to FluiddPi and tested the webcam with the latest version available on the App Store. On my end, it's working fine. Can you attach a screenshot of the webcam page?

Just to be sure, there is a small icon in the upper right corner. There, you can switch between print image and webcam stream. Maybe it's set to the print image?

image

adrianocr commented 2 years ago

Yeah check these two pics out: C40B83DF-D0A6-4EF3-A6E4-AB3B9F79190C 704ED4B4-7E76-49A2-A3AF-7F92D262E47F

It works fine if I open fluidd in my browser and also using the Mobileraker app. But fails in rc klipper 3D.

My setup is in docker containers utilizing mkuf/prind so maybe it’s an issue there? But I don’t know if that makes sense because like I said it works fine via the browser and through mobileraker

adrianocr commented 2 years ago

And I have a bunch of warnings and errors in the event logs, see pics:

5CBECD2F-D806-4F22-BFCA-C86DB2561F16 4AE3D937-6CC6-463B-99C5-6AC9CDE4C3DA

AndreasReitberger commented 2 years ago

@adrianocr Thanks for sharing your screenshots. In the first one, with the black background, the webcam should be running. At least the app settings for it are fine. Can you share your webcam config from FluiddPi?

Warnings are fine, the errors will be addressed. I'm currently working on the update and fixed those errors with the "cpu_temp" conversion already.

I hope to get an update ready this weekend.

adrianocr commented 2 years ago

@AndreasReitberger I'm not actually using fluiddpi, I'm running klipper, moonraker, and fluidd in individual docker containers. So if your question is specifically fluiddpi related then I can't really answer it.

But having said that, I've tried two ways; 1) via the moonraker.cfg file, and through the fluidd UI. Neither of them seem to work with RC Klipper 3D. Screenshots:

fluidd Configuration 2022-09-14 at 11 54 25 AM

fluidd Settings 2022-09-14 at 11 56 27 AM

adrianocr commented 2 years ago

Also it may be worth pointing out that the camera list in RC Klipper 3D doesn’t populate any cameras in the drop-down list: 815C00FE-190A-43AD-8A79-77D6951734AD

AndreasReitberger commented 2 years ago

Hi @adrianocr I actually ment the web dashboard provided by fluidd. Maybe FluiddPi was confusing, but you actually posted the right screenshot.

Yes, that the cam list is empty could be a good point to start with.

I'll do some investigating and come back to you.

Thanks for your help!

AndreasReitberger commented 2 years ago

Hi @adrianocr can you try following commands in your browser and send me the result, please? You must do this while you are logged in in your dashboard.

Also check if this is your IP.

http://192.168.0.5/server/database/item?namespace=fluidd&key=cameras

This should return a JSON object with your cameras. If this doesn't work, add your API key into the query.

http://192.168.0.5/server/database/item?namespace=fluidd&key=cameras?token=YOUR_API

Eventually, if the previous commands worked, get the whole settings as JSON string while using this command.

http://192.168.0.5/server/database/item?namespace=fluidd

Thank you!

adrianocr commented 2 years ago
{
  "result": {
    "namespace": "fluidd",
    "key": "cameras",
    "value": {
      "activeCamera": "b2d3a921-987d-4838-a006-31504fbf9588"
    }
  }
}

and

{
  "result": {
    "namespace": "fluidd",
    "key": null,
    "value": {
      "cameras": {
        "activeCamera": "b2d3a921-987d-4838-a006-31504fbf9588"
      },
      "charts": {},
      "console": {
        "commandHistory": [
          "POWEROFF",
          "SHUTDOWN",
          "SAVE_CONFIG",
          "RESTART",
          "TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.020",
          "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500",
          "TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.020",
          "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500",
          "TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.020",
          "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500",
          "TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.020",
          "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500",
          "TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.020",
          "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500",
          "TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.020",
          "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500",
          "TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 FACTOR=.020",
          "SET_VELOCITY_LIMIT SQUARE_CORNER_VELOCITY=1 ACCEL=500",
          "M300 S440 P200",
          "M300 S440 P200"
        ]
      },
      "layout": {
        "layouts": {
          "dashboard": {
            "container1": [
              {
                "id": "printer-status-card",
                "enabled": true,
                "collapsed": false
              },
              {
                "id": "camera-card",
                "enabled": true,
                "collapsed": false
              },
              {
                "id": "toolhead-card",
                "enabled": true,
                "collapsed": false
              },
              {
                "id": "macros-card",
                "enabled": true,
                "collapsed": false
              },
              {
                "id": "outputs-card",
                "enabled": true,
                "collapsed": false
              },
              {
                "id": "printer-limits-card",
                "enabled": true,
                "collapsed": false
              },
              {
                "id": "retract-card",
                "enabled": true,
                "collapsed": false
              }
            ]
          }
        }
      },
      "macros": {},
      "uiSettings": {
        "general": {
          "confirmOnEstop": true,
          "cameraFullscreenAction": "rawstream"
        }
      }
    }
  }
}
AndreasReitberger commented 2 years ago

Thanks for the quick respone. The "cameras" respone looks different on your end as on my end. I get the full settings from the cameras when calling this function.

It actually should hold following properties.

IEnumerable<KlipperDatabaseWebcamConfig> temp = fluiddObject.Cameras.Select(item => new KlipperDatabaseWebcamConfig()
                            {
                                Id = item.Id,
                                Enabled = item.Enabled,
                                Name = item.Name,
                                FlipX = item.FlipX,
                                FlipY = item.FlipY,
                                Service = item.Type,
                                TargetFps = item.Fpstarget,
                                Url = item.Url,
                            });

https://github.com/AndreasReitberger/KlipperRestApiSharp/blob/main/source/KlipperSharpWebApi/KlipperSharpWebApi/KlipperClient.cs#L6660

For testing, can you add a second camera in your fluidd settings? Just give it a different name and then repeat the first command.

adrianocr commented 2 years ago

@AndreasReitberger I added a second cam and repeated. The only thing that changes is the activeCamera value. I don't get any of the other keys you are looking for above.

I'm going to try mainsail later today and see if maybe that makes a difference.

adrianocr commented 2 years ago

Tried mainsail (docker containers are awesome). Unfortunately the app still didn't connect and apparently the "cameras" key isn't valid in the URL you wanted me to test

Sorry for all the difficulty on this, man

AndreasReitberger commented 2 years ago

Yes for MainsailOS add as namespace mainsail and as key webcam or webcams.

http://192.168.0.5/server/database/item?namespace=mainsail&key=webcams

I will update the tool if no cameras are found, it will use the default url.

No worry, I'm glad to help. I'll let you know when the new version is ready.

Best, Andreas

AndreasReitberger commented 2 years ago

Hi @adrianocr,

I published a fix which should fix your issue. I'll release a new app update soon. If the bug is not fixed for you, please open a new issue. Thank you!

AndreasReitberger commented 2 years ago

Hi @adrianocr I just uploaded a new beta to TestFlight https://testflight.apple.com/join/TyguKzt9

Once Apple has approved it, please test the new version. The webcam should now work for you :)

adrianocr commented 2 years ago

Awesome, thank you for looking into this.

And a quick suggestion; maybe allow the webcam URL to get input manually? That is how it works in mobileraker. I manually specify http://192.168.0.5/webcam?action=stream and presto