private IEnumerator CameraLoop()
        {
            camera_coroutine_running = true;
            while (camera_coroutine_running)
            {
                camera_loop_running = true;
                if (_webcam != null && _webcam.IsUpdated())
                {
                    //Debug.Log("webcam Pikkart Camera Loop camera updated");
                    PikkartARCore.SetCameraOriginalSize(Constants.CAMERA_REQUESTED_WIDTH, Constants.CAMERA_REQUESTED_HEIGHT);

                    PikkartARCore.CopyNewFrame(_webcam.GetDataAsIntPtr(), _webcam.GetCameraWidth(), _webcam.GetCameraHeight());
                    //PikkartARCore.CopyNewFrame32(_webcam.GetDataAsColor32(), Constants.CAMERA_REQUESTED_WIDTH, Constants.CAMERA_REQUESTED_HEIGHT);
                    //_webcam.UploadCameraDataAsColor32();

                    bool found_something = PikkartARCore.ImageProcessing();

                    if (Screen.currentResolution.width > Screen.currentResolution.height)
                    {
                        if (cam != null)
                        {
                            cam.projectionMatrix = MatrixUtils.GetAlternateLandscapeProjectionMatrix();
                        }
                    }
                    else
                    {
                        if (cam != null)
                        {
                            cam.projectionMatrix = MatrixUtils.GetAlternatePortraitProjectionMatrix();
                        }
                    }

                    String markerFound  = "";
                    int    logo_payload = -1;

                    int numTrackedMarkers = 0;
                    if (found_something)
                    {
                        numTrackedMarkers = PikkartARCore.GetTrackedInternalIDs(trackedMarkersData.GetArray());
                    }
                    //Debug.Log("markerFound=numTrackedMarkers " + numTrackedMarkers);
                    if (numTrackedMarkers > 0)
                    {
                        int size = PikkartARCore.GetMarkerNameFromInternalIDs(trackedMarkersData.GetArray()[0], markerFoundPtr);
                        markerFound = Marshal.PtrToStringAnsi(markerFoundPtr, size - 1);
                        if (IsSeethroughDevice)
                        {
                            size = PikkartARCore.GetMarkerPoseInternalID_WithPrediction(trackedMarkersData.GetArray()[0], PredictionFrames, viewMatrixData.GetArray());
                        }
                        else
                        {
                            size = PikkartARCore.GetMarkerPoseInternalID(trackedMarkersData.GetArray()[0], viewMatrixData.GetArray());
                        }
                        logo_payload = PikkartARCore.MarkerHasLogoInternalId(trackedMarkersData.GetArray()[0]);
                        if (logo_payload > 0)
                        {
                            recognitionManager.ARLogoFound(trackedMarkersData.GetArray()[0], logo_payload);
                        }
                        else
                        {
                            logo_payload = -1;
                        }
                    }
                    else
                    {
                        markerFound = "";
                    }

                    if (markerFound == "")
                    {
                        if (recognitionManager != null)
                        {
                            if (recognitionManager.IsRecognitionRunning())
                            {
                                recognitionManager.LocalMarkerNotFound();
                            }
                        }
                        viewMatrix = Matrix4x4.identity;
                    }
                    else if (markerFound != "")
                    {
                        if (IsSeethroughDevice)
                        {
                            if (previousMarkerFound != "" && markerFound != previousMarkerFound)
                            {
                                recognitionManager.MarkerTrackingLost(previousMarkerFound);
                            }
                        }
                        if (recognitionManager != null && previousMarkerFound == "")
                        {
                            recognitionManager.LocalMarkerFound(markerFound, trackedMarkersData.GetArray()[0]);
                        }
                        viewMatrix = MatrixUtils.GetViewMatrixFromArray(viewMatrixData.GetArray());

                        viewMatrix = MatrixUtils.GetRotationMatrixForOrientation() * viewMatrix;
                    }

                    if (!IsSeethroughDevice)
                    {
                        if (previousMarkerFound != "" && markerFound == "")
                        {
                            recognitionManager.MarkerTrackingLost(previousMarkerFound);
                        }
                    }
                    previousMarkerFound = markerFound;

                    MarkerUpdate();

#if UNITY_EDITOR
                    _webcam.UpdateVisibleFrame();
#else
                    if (!IsSeethroughDevice)
                    {
                        GL.IssuePluginEvent(PikkartARCore.GetRenderEventFunc(), 666);
                    }
#endif

                    //Debug.Log("markerFound=" + markerFound);
                }
                //yield return new WaitUntil(() => _webcam!=null && _webcam.IsUpdated() == true);
                //yield return null;
                yield return(new WaitForEndOfFrame());
            }
            camera_loop_running = false;
        }
 protected bool IsRecognitionActive()
 {
     return(_recognitionManager.IsRecognitionRunning());
 }