コード例 #1
0
    /// <summary>
    /// Initializes the ManoMotion Frame and lets the subscribers of the event know of its information.
    /// </summary>
    private void InitializeManoMotionFrame()
    {
        currentManoMotionFrame = new ManoMotionFrame();
        ResizeManoMotionFrameResolution(STARTING_WIDTH, STARTING_HEIGHT);
        currentManoMotionFrame.orientation = Input.deviceOrientation;

        if (OnFrameInitialized != null)
        {
            OnFrameInitialized(currentManoMotionFrame);

            Debug.Log("Initialized input parameters");
        }
        else
        {
            Debug.LogWarning("Noone is subscribed to OnFrameInitialized");
        }

        if (OnAddonSet != null)
        {
            OnAddonSet(AddOn.DEFAULT);

            Debug.Log("Initialized addon");
        }
        else
        {
            Debug.LogWarning("Noone is subscribed to OnFrameInitialized");
        }
    }
コード例 #2
0
    protected void ProcessManomotion(ManoMotionFrame newFrame)
    {
        if (isInitialized)
        {
            visualization_info.rgb_image.SetPixels32(newFrame.pixels);
            visualization_info.rgb_image.Apply();
            CalculateFPSAndProcessingTime();


            try
            {
                long start = System.DateTime.UtcNow.Millisecond + System.DateTime.UtcNow.Second * 1000 + System.DateTime.UtcNow.Minute * 60000;
                ProcessFrame();
                long end = System.DateTime.UtcNow.Millisecond + System.DateTime.UtcNow.Second * 1000 + System.DateTime.UtcNow.Minute * 60000;
                if (start < end)
                {
                    processing_time_list.Add((int)(end - start));
                }
            }
            catch (System.Exception ex)
            {
                Debug.Log("exeption: " + ex.ToString());
            }

            if (OnFrameManoMotionProcessed != null)
            {
                OnFrameManoMotionProcessed();
            }
        }
    }
コード例 #3
0
 /// <summary>
 /// Resizes the resolution,theframe array and visualization information to fit a frame dimensions.
 /// </summary>
 /// <param name="newFrame">New frame.</param>
 void ResizeToFitFrame(ManoMotionFrame newFrame)
 {
     if (isInitialized)
     {
         SetResolution(newFrame.width, newFrame.height);
         SetFrameArray(newFrame.pixels);
         InstantiateVisualisationInfo(newFrame.width, newFrame.height);
         Debug.Log("ManoMotion Resize To Fit Frame");
     }
 }
コード例 #4
0
 void SaveTextureToFile(ManoMotionFrame newFrame)
 {
     if (delay5 % 10 == 0)
     {
         frameCounter++;
         byte[] bytes = newFrame.texture.EncodeToPNG();
         string path  = Application.persistentDataPath + "/" + newFrame.texture.width + "x" + newFrame.texture.height + ", " + inputRenderTexture.width + "x" + inputRenderTexture.height + "-" + frameCounter.ToString() + "deviceOrientation" + Input.deviceOrientation.ToString() + ".png";
         Debug.Log("Saving in Path: " + path);
         File.WriteAllBytes(path, bytes);
     }
     delay5++;
 }
コード例 #5
0
 /// <summary>
 /// Gets the camera frame pixel colors.
 /// </summary>
 protected void GetCameraFramePixelColors(ManoMotionFrame newFrame)
 {
     if (framePixelColors.Length != newFrame.pixels.Length || visualization_info.rgb_image.width != newFrame.texture.width || visualization_info.rgb_image.height != newFrame.texture.height)
     {
         SetResolutionValues(newFrame.width, newFrame.height);
     }
     try
     {
         framePixelColors = newFrame.pixels;
     }
     catch (System.Exception ex)
     {
         Debug.LogError(ex);
     }
 }
コード例 #6
0
    /// <summary>
    /// Initializes the ManoMotion Frame and lets the subscribers of the event know of its information.
    /// </summary>
    private void InitializeManoMotionFrame()
    {
        currentManoMotionFrame = new ManoMotionFrame();
        ResizeManoMotionFrameResolution(STARTING_WIDTH, STARTING_HEIGHT);

        if (OnFrameInitialized != null)
        {
            OnFrameInitialized(currentManoMotionFrame);
            Debug.Log("Initialized input parameters");
        }
        else
        {
            Debug.LogWarning("None is subscribing to OnFrameInitialized");
        }
    }
コード例 #7
0
    /// <summary>
    /// Instantiates the manager info.
    /// </summary>
    protected void InstantiateSession(ManoMotionFrame frame)
    {
        manomotion_session = new Session();
#if UNITY_ANDROID
        manomotion_session.current_plataform = Platform.UNITY_ANDROID;
#elif UNITY_IOS
        manomotion_session.current_plataform = Platform.UNITY_IOS;
#endif
        manomotion_session.image_format               = ImageFormat.RGBA_IMAGE;
        manomotion_session.orientation                = frame.orientation;
        manomotion_session.add_on                     = AddOn.DEFAULT;
        manomotion_session.smoothing_controller       = 0.5f;
        manomotion_session.enabled_features.pinch_poi = 1;
        Debug.Log("Session Created");
    }
コード例 #8
0
 /// <summary>
 /// Gets the camera frame pixel colors.
 /// </summary>
 protected void GetCameraFramePixelColors(ManoMotionFrame newFrame)
 {
     if (framePixelColors.Length != newFrame.pixels.Length || visualization_info.rgb_image.width != newFrame.texture.width || visualization_info.rgb_image.height != newFrame.texture.height)
     {
         Debug.LogError("GetCameraFramePixelColors lengths were not matching, called resize");
         Handheld.Vibrate();
         SetResolutionValues(newFrame.width, newFrame.height);
         SetFrameArray(framePixelColors);
     }
     try
     {
         framePixelColors = newFrame.pixels;
     }
     catch (System.Exception ex)
     {
         Debug.LogError(ex);
     }
 }
コード例 #9
0
    /// <summary>
    /// Initializes the Input Parameters
    /// </summary>
    protected override void InitializeInputParameters()
    {
        textureFormat = TextureFormat.RGBA32;

        frameTexture       = new Texture2D(MinRezValue, MaxRezValue, textureFormat, false);
        pixelColors        = new Color32[MaxRezValue * MinRezValue];
        inputRenderTexture = new RenderTexture(MinRezValue, MaxRezValue, 0);

        RenderTexture.active = inputRenderTexture;
        currentFrame         = new ManoMotionFrame();
        ResizeCurrentFrameTexture(inputRenderTexture.width, inputRenderTexture.height);

        if (OnFrameInitialized != null)
        {
            OnFrameInitialized(currentFrame);
        }

        if (OnAddonSet != null)
        {
            OnAddonSet(AddOn.ARFoundation);
        }
    }
コード例 #10
0
 /// <summary>
 /// Respond to the event of a ManoMotionFrame being sent for processing.
 /// </summary>
 /// <param name="newFrame"></param>
 void HandleNewFrame(ManoMotionFrame newFrame)
 {
     GetCameraFramePixelColors(newFrame);
     UpdateTexturesWithNewInfo();
 }
コード例 #11
0
 /// <summary>
 /// Respond to the event of a ManoMotionFrame being initialized.
 /// </summary>
 /// <param name="newFrame"></param>
 void HandleManoMotionFrameInitialized(ManoMotionFrame newFrame)
 {
     SetResolutionValues(newFrame.width, newFrame.height);
     InstantiateVisualisationInfo();
 }
コード例 #12
0
 /// <summary>
 /// Respond to the event of a ManoMotionFrame resized.
 /// </summary>
 /// <param name="newFrame"></param>
 void HandleManoMotionFrameResized(ManoMotionFrame newFrame)
 {
     SetResolutionValues(newFrame.width, newFrame.height);
 }
コード例 #13
0
 /// <summary>
 /// Initializes the frame clone components.
 /// </summary>
 void InitializeFrame()
 {
     currentFrame = new ManoMotionFrame();
 }
コード例 #14
0
 /// <summary>
 /// Respond to the event of a ManoMotionFrame resized.
 /// </summary>
 /// <param name="newFrame"></param>
 void HandleManoMotionFrameResized(ManoMotionFrame newFrame)
 {
     Debug.Log("Handled ManoMotionFrameResized Event");
     SetResolutionValues(newFrame.width, newFrame.height);
 }
コード例 #15
0
 /// <summary>
 /// Picks the resolution.
 /// </summary>
 protected void InitializeManoMotionManager(ManoMotionFrame newFrame)
 {
     InstantiateSession(newFrame);
     InstantiateHandInfos();
     InitiateLibrary();
 }