Giter VIP home page Giter VIP logo

Comments (7)

Jasonfinish avatar Jasonfinish commented on August 11, 2024

anybody can help me ?

from numpy.net.

henon avatar henon commented on August 11, 2024

Please post a small code example of what you are trying to do.

from numpy.net.

simonbuehler avatar simonbuehler commented on August 11, 2024

hi, have the same question, how would i convert this code:

rects = detector.detectMultiScale(gray, scaleFactor=1.1,minNeighbors=5, minSize=(30, 30),flags=cv2.CASCADE_SCALE_IMAGE)
    # ensure at least one face was found before continuing
    if len(rects) > 0:
        # determine the largest face area
        rect = sorted(rects, reverse=True,key=lambda x: (x[2] - x[0]) * (x[3] - x[1]))[0]
        (fX, fY, fW, fH) = rect
        # extract the face ROI from the image, then pre-process
        # it for the network
        roi = gray[fY:fY + fH, fX:fX + fW]
        roi = cv2.resize(roi, (48, 48))
        roi = roi.astype("float") / 255.0
        roi = img_to_array(roi)
        roi = np.expand_dims(roi, axis=0)
        
        # make a prediction on the ROI, then lookup the class# label
        preds = model.predict(roi)[0]

so here the input is a opencv mat and keras needs the nparray of the rectangle

from numpy.net.

henon avatar henon commented on August 11, 2024

Which library are you using to call OpenCV from C#?

from numpy.net.

simonbuehler avatar simonbuehler commented on August 11, 2024

I'm using opencvsharp

currently i'm at this state below which looks fishy - but loading the Model.LoadModel("epoch_90.hdf5"); throwing a EEFileLoadException keeps me from testing if it works yet

Mat roi = frameMat[rects[0]];
Cv2.Resize(roi, roi, new OpenCvSharp.Size(48, 48));
float[] result;
roi.GetArray(out result);
var test = np.asfarray(result) / 255;
test = ImageUtil.ImageToArray(test);
test = np.expand_dims(test, 0);

NDarray nDarray = model.Predict(test[0]);
Console.WriteLine(nDarray.argmax());

from numpy.net.

henon avatar henon commented on August 11, 2024

Is it possible to extract the array values from the OpenCV mat into a C# array? Then you can create an NDarray from those easily and pass it on to Keras

from numpy.net.

Oceania2018 avatar Oceania2018 commented on August 11, 2024

@simonbuehler Take a look at SharpCV. It combines the NDArray and Mat.

from numpy.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.