protected virtual void Start()
    {
        Application.targetFrameRate = 60;
        textureParameters           = new ARucoUnityHelper.TextureConversionParams();
        SetUpPhysicalCamera(webCamSettings.cameraIndex);

        rawImage         = imageGameObject.GetComponent <RawImage>();
        imgRectTransform = imageGameObject.GetComponent <RectTransform>();
    }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        cameraPoseTracker            = arCamera.GetComponent <PositionAndRotationTracker>();
        texParam                     = new ARucoUnityHelper.TextureConversionParams();
        cameraManager.frameReceived += OnCameraFrameReceived;
        Init();

        if (showOpenCvTexture)
        {
            openCvTexture.gameObject.SetActive(true);
        }
    }
Exemple #3
0
    private bool OnProcessTexture(WebCamTexture input, ref Texture2D output,
                                  ARucoUnityHelper.TextureConversionParams textureParameters)
    {
        textureParameters.FlipHorizontally = false;
        if (!float.TryParse(patternSizeString.value, out squareSizeMeters))
        {
            return(false);
        }

        squareSizeMeters = float.Parse(patternSizeString.value);

        mat = ARucoUnityHelper.TextureToMat(input, textureParameters);

        //Debug.Log("Width: " + mat.Width + " Height: " + mat.Height);

        imageWidth  = mat.Width;
        imageHeight = mat.Height;


        Cv2.CvtColor(mat, grayMat, ColorConversionCodes.BGR2GRAY);

        if (reset)
        {
            ResetCalibrationImmediate();
            reset = false;
        }

        if (captureFrame)
        {
            RegisterCurrentCalib();
            captureFrame = false;
        }

        if (calibrate)
        {
            StartCalibrateAsync();
            calibrate = false;
        }


        output = ARucoUnityHelper.MatToTexture(mat, output);

        mat.Release();
        return(true);
    }
Exemple #4
0
    private bool ProcessTexture(WebCamTexture input, ref Texture2D output,
                                ARucoUnityHelper.TextureConversionParams textureParameters)
    {
        imgBuffer = ARucoUnityHelper.TextureToMat(input, textureParameters);
        //Debug.Log("New image Assigned");

        timeCount += Time.deltaTime;

        if (threadCounter == 0 && timeCount >= markerDetectorPauseTime)
        {
            imgBuffer.CopyTo(img);
            Interlocked.Increment(ref threadCounter);
            timeCount = 0;
        }

        updateThread = true;

        if (outputImage)
        {
            if (drawMarkerOutlines)
            {
                CvAruco.DrawDetectedMarkers(img, corners, ids);
            }

            output = ARucoUnityHelper.MatToTexture(img, output);
            //Debug.Log("Marker image Rendered");
            outputImage = false;
        }
        else
        {
            output = ARucoUnityHelper.MatToTexture(imgBuffer, output);
            //Debug.Log("Camera image Rendered");
        }

        imgBuffer.Release();
        return(true);
    }