Coder Social home page Coder Social logo

opencv-plus-unity's Introduction

OpenCV+Unity

OpenCV plus Unity

Originally created by Gobra

OpenCV plus Unity

Its a wrapper for OpenCV precompiled libraries for most of the systems available in Unity You can create projects that use the OpenCV capabilities in mobile projects and integrate custom AR solutions.

Documentation

OpenCV plus Unity original creator left the plugin some time ago and the website with documentation has been lost in internet There is some way to recreate the documentation by just looking on the source code but it should be somewhat group effort. Right now you can use original documentation notes

Build it Yourself

To run it in Unity Editor or Android you have to prebuild the libraries Yourself

bash utils/build-everything.sh --version 1.0 --ndkpath {ndkpath}

opencv-plus-unity's People

Contributors

gobra avatar thebricktop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

opencv-plus-unity's Issues

Cv2.SolvePnP Methods an error

OpenCVException: npoints >= 0 && npoints == std::max(ipoints.checkVector(2, CV_32F), ipoints.checkVector(2, CV_64F))

  Texture2D _texture2D = new Texture2D(640, 480, TextureFormat.ARGB32, true);
        _texture2D.SetPixels(m_webCamTexture.GetPixels());
        _texture2D.Apply();

        (Point2d[] _imagePoints, Point3d[] _modelPoints) = this.GetCurPoints(_texture2D.width, _texture2D.height);
        m_InputMat = Unity.TextureToMat(_texture2D);
        Cv2.Flip(m_InputMat, m_InputMat, FlipMode.Y);     //图像左右翻转

        int focal_length = m_InputMat.Cols;
        int[] center = new int[] {Mathf.FloorToInt (m_InputMat.Cols * 0.5f), Mathf.FloorToInt( m_InputMat.Rows * 0.5f) };
        Mat camera_matrix = new Mat(3, 3, MatType.CV_64F, new long[,] { { focal_length, 0, center[0]}, { 0, focal_length, center[1]}, { 0, 0, 1 } });
        // camera_matrix.SetArray(3, 3, new double[,] { { focal_length, 0, center.X }, { 0, focal_length, center.Y }, { 0, 0, 1 } });

        Mat dist_coeffs = new Mat(4, 1, MatType.CV_64F, new long[,] { { 0, 0, 0, 0 } });
        //dist_coeffs.SetArray(4, 1, new double[,] { { 0, 0, 0, 0 } });
        
        Mat rotation_vector = new Mat();
        Mat translation_vector = new Mat();
        InputArray modelArray = InputArray.Create(_modelPoints);
        InputArray imageArray = InputArray.Create(_imagePoints);

        Cv2.SolvePnP(modelArray, imageArray, camera_matrix, dist_coeffs, rotation_vector, translation_vector);

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.