Giter Site home page Giter Site logo

Comments (12)

TheWorldEndsWithUs avatar TheWorldEndsWithUs commented on August 10, 2024 1

Okay, I've been bouncing through different issues all day. I will try to list all of my solutions here.

First download both the cpu runtime (GPU doesn't work for windows) and the mediapipe.net packages by changing the version in nuget.
The Mediapipe.net package should be 0.8.10
The CPU runtime should be 0.8.9

Then you need to get the mediapipe folder from here (download the repo as a zip, extract the media pipe folder to the same folder as your .exe)

Include the mediapipe libraries and Emgu

using Mediapipe.Net.Calculators; using Mediapipe.Net.External; using Mediapipe.Net.Framework.Format; using Mediapipe.Net.Framework.Protobuf; using Emgu.CV;

Next, SeeShark didn't work for me. I ended up using opencv (emgu.cv) instead. I created a timer on windows forms and I set the interval to 1000 / FPS. (Create a variable called FPS and assign it 30 to start).

` int FPS = 30;

    VideoCapture capture;
    private void Form1_Load(object sender, EventArgs e)
    {
        timer1.Interval = 1000 / FPS;
        capture = new VideoCapture();

        calculator = new FaceMeshCpuCalculator();
        calculator.OnResult += handleLandmarks;
        calculator.Run();

    }`

Then you need to get the pictures displaying on the screen (use nuget to get emgu windows runtime and emgu.cv.bitmap package)

` private void timer1_Tick(object sender, EventArgs e)
{
Mat frame = capture.QueryFrame();
Bitmap frameAsBitmap = frame.ToBitmap();
pictureBox1.Image = frameAsBitmap;

        ReadOnlySpan<byte> byteSpan = new ReadOnlySpan<byte>(frame.GetRawData());

        ImageFrame imgframe = new ImageFrame(ImageFormat.Srgb,
               frame.Width, frame.Height, frame.Step, byteSpan);

        using ImageFrame img = calculator.Send(imgframe);
    }`

If you have a code above and the handleLandmarks method from the example and download the tflite models you need from this url and add them to the appropriate folders for whatever errors you are getting. Then face landmark detection will work.

Note: The face landmarks will not be drawn to the screen, you need to do that yourself, but they will be detected.

So far hands has been a lot more difficult to get up and running. The first part is easy, replace FaceMeshCpuCalculator with HandCpuCalculator in the code. You will also have to change your handleLandmarks function to not accept a list of NormalizedLandmarkList, but a single normalizedLandmarkList, then the real work begins. You must edit and rename graph files (found in mediapipe\graphs\hand_tracking (the folder you copied to the .exe directory earlier).

I don't remember everything I did, but I will try to list the things that got me to my current point (it's still not working). First you should know the pbtxt files are the graph files. They have code like files that have inputs and outputs that connect to eachother. The first error should say something like hand_tracking_desktop_live_cpu doesn't exist. It technically does, it just doesn't have the _cpu at the end of it. So find the hand_tracking_desktop_live file and rename it to hand_tracking_desktop_live_cpu.

Then you need to edit the cpu file with information I found from this comment. Edit the node under the # Detects/tracks hand landmarks comment. Change output_stream: "LANDMARKS:landmarks" to output_stream: "LANDMARKS:hand_landmarks". Do the same for the input stream in the same file below that node. input_stream: "LANDMARKS:landmarks" to input_stream: "LANDMARKS:hand_landmarks".

Then go into the hand_renderer_cpu file in the subgraphs folder. Change all occurrences of landmarks to hand_landmarks. Then it prompted me to download more model files from the link above. That is where I am currently. After downloading those files, It's currently crashing with no errors again, so I need to keep trying to mess with the graph and get it all working. I'll report back any findings.

from mediapipe.net.

GeorgeS2019 avatar GeorgeS2019 commented on August 10, 2024 1

There is now GitHub CI windows build v0.10.13 using vs2019
PR submitted to Google.

Hopefully the support for windows is no longer experimental

from mediapipe.net.

sr229 avatar sr229 commented on August 10, 2024

We've only tried face pose but anything on 0.8.x should just work.

from mediapipe.net.

sr229 avatar sr229 commented on August 10, 2024

I'll be pinning this for other people, this is a good solution for those who want it to get running. I've been planning to rewrite this for a while, but for now this is a good workaround you documented.

from mediapipe.net.

TheWorldEndsWithUs avatar TheWorldEndsWithUs commented on August 10, 2024

Thanks for the pin! Unfortunately, I wasn't able to get it working. When you change "hand_landmarks" to "landmarks" in all of the files and you have all of the models downloaded and in their correct places the application crashes immediately. I used the event viewer to get an error code linked to ucrtbase.dll. I put the code into chatgpt, and it seems to think it's a stack overflow error.

from mediapipe.net.

GeorgeS2019 avatar GeorgeS2019 commented on August 10, 2024

@TheWorldEndsWithUs
@sr229
We now have C# wrappers for v0.10.09 Mediapipe in Godot for most examples

We are aiming upgrading to V0.10.11

from mediapipe.net.

TheWorldEndsWithUs avatar TheWorldEndsWithUs commented on August 10, 2024

@GeorgeS2019 That's fantastic! My Google and Github searches lead me to the discussion you started about a year ago regarding the C# support, and this wrapper generator for the extension. However, I'm not too sure what I am looking at. Are you able to run the landmark detection without using Godot? Does it work within a standalone C# project?

from mediapipe.net.

GeorgeS2019 avatar GeorgeS2019 commented on August 10, 2024

Godot could run as a library...it is cutting edge area need a lot to check
.
We are now pushing towards the latest version of Mediapipe

from mediapipe.net.

GeorgeS2019 avatar GeorgeS2019 commented on August 10, 2024

C# wrapper code
https://github.com/Delsin-Yu/CSharp-Wrapper-Generator-for-GDExtension/pull/26/files

from mediapipe.net.

sr229 avatar sr229 commented on August 10, 2024

I think this is a little out of topic since the entire point of this project is to use MediaPipe regardless of what framework you're using, so unless you're willing to help bring this with vendor neutrality in mind this does not really mean anything.

from mediapipe.net.

GeorgeS2019 avatar GeorgeS2019 commented on August 10, 2024

@sr229
The challenge of working with Mediapipe in .Net is to build the dll
Then, the .Net wrapper generation automatically.
Both are not trivial

from mediapipe.net.

sr229 avatar sr229 commented on August 10, 2024

Hence it takes us time to port from the MediaPipe Unity plugin we derive from - those take tremendous amounts of time to port due to the amount of changes, inasmuch as we would love it to be automated with ClangSharp.

To reiterate myself, please if you have an interest to use this and get this to work, please help us.

from mediapipe.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.