public void startRunning()
 {
     if (state == State.BASE_INITIALISED)
     {
         bool ret = false;
         if (useCameraParamFile)
         {
             ret = ARUWP.aruwpStartRunning("Data/StreamingAssets/" + cameraParam);
         }
         else
         {
             if (cameraParamBuffer != null)
             {
                 ret = ARUWP.aruwpStartRunningBuffer(cameraParamBuffer, cameraParamBuffer.Length);
             }
             else
             {
                 Debug.Log(TAG + ": cameraParamBuffer is null");
             }
         }
         if (ret)
         {
             state = State.WAITING_FOR_FRAME;
         }
         else
         {
             Debug.Log(TAG + ": startRunning() fails");
         }
     }
     else
     {
         Debug.Log(TAG + ": startRunning() fails unless current status is BASE_INITIALISED");
     }
 }
    public static string getVersionString()
    {
        StringBuilder buffer = new StringBuilder(20);

        ARUWP.aruwpGetARToolKitVersion(buffer, 20);
        return(buffer.ToString());
    }
 /// <summary>
 /// Update tracking information, called by ARUWPController.cs. [internal use]
 /// </summary>
 public void UpdateTrackingInfo()
 {
     if (id != -1)
     {
         if (ARUWP.aruwpQueryMarkerTransformation(id, __info.trans))
         {
             if (type != MarkerType.multi)
             {
                 __info.confidence = ARUWP.aruwpGetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_SQUARE_CONFIDENCE);
             }
             __info.visible = true;
         }
         else
         {
             __info.visible    = false;
             __info.confidence = 0.0f;
         }
         Interlocked.Exchange(ref _info, __info);
         signalTrackingUpdated = true;
     }
     else
     {
         Debug.Log(TAG + ": Transformation not valid for id -1");
     }
 }
Beispiel #4
0
 // return true if visible
 // return false if error or invisible
 public bool updateMarkerTracking()
 {
     if (id != -1)
     {
         if (ARUWP.aruwpQueryMarkerTransformation(id, trans))
         {
             transMatrix = ARUWPUtils.ConvertARUWPFloatArrayToMatrix4x4(trans);
             if (performMagicFunction)
             {
                 MagicFunction();
             }
             if (type != MarkerType.multi)
             {
                 confidence = ARUWP.aruwpGetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_SQUARE_CONFIDENCE);
             }
             visible = true;
             return(true);
         }
         else
         {
             visible    = false;
             confidence = 0.0f;
             return(false);
         }
     }
     else
     {
         Debug.Log(TAG + ": Transformation not valid for id -1");
         visible = false;
         return(false);
     }
 }
 /// <summary>
 /// Remove the current marker from the controller, called by ARUWPController.cs.
 /// [internal use]
 /// </summary>
 public void RemoveMarker()
 {
     if (id != -1)
     {
         if (HasNativeHandle())
         {
             if (ARUWP.aruwpRemoveMarker(id))
             {
                 Debug.Log(TAG + ": Marker removed with UID " + id);
                 ARUWPController.markers.Remove(id);
                 id = -1;
             }
             else
             {
                 Debug.Log(TAG + ": Cannot remove marker with UID " + id);
             }
         }
         else
         {
             Debug.Log(TAG + ": RemoveMarker() unsupported status");
         }
     }
     else
     {
         Debug.Log(TAG + ": Cannot remove marker with id -1");
     }
 }
    public static void logFrameInforamtion()
    {
        int           width, height, pixelSize;
        StringBuilder buffer = new StringBuilder(30);

        ARUWP.aruwpGetFrameParams(out width, out height, out pixelSize, buffer, 30);
        Debug.Log("ARUWP: Frame width and height: " + width + "x" + height);
        Debug.Log("ARUWP: Frame pixel size: " + pixelSize);
        Debug.Log("ARUWP: Frame pixel format string: " + buffer.ToString());
    }
    private async Task Detect(Color32[] color)
    {
        IntPtr imageHandle = await getImageHandleAsync(color);

        ARUWP.aruwpUpdate(imageHandle);
        if (ExecuteOnMainThread.Count == 0)
        {
            ExecuteOnMainThread.Enqueue(() => {
                DetectDone();
            });
        }
    }
    /// <summary>
    /// Add this marker to the controller, so that it will be tracked. This function is
    /// called by ARUWPController.cs. [internal use]
    /// </summary>
    public void AddMarker()
    {
        if (HasNativeHandle())
        {
            string str = "";
            switch (type)
            {
            case MarkerType.single:
                str = "single;Data/StreamingAssets/" + singleFileName + ";" + singleWidth;
                break;

            case MarkerType.single_barcode:
                str = "single_barcode;" + singleBarcodeID + ";" + singleWidth;
                break;

            case MarkerType.single_buffer:
                if (singleBufferBuffer == null)
                {
                    Debug.Log(TAG + ": Marker buffer is not set\n");
                    return;
                }
                str = "single_buffer;" + singleWidth + ";buffer=" + singleBufferBuffer;
                break;

            case MarkerType.multi:
                str = "multi;Data/StreamingAssets/" + multiFileName;
                break;
            }
            id = ARUWP.aruwpAddMarker(str);
            if (id != -1)
            {
                ARUWPController.markers.Add(id, this);
                Debug.Log(TAG + ": Marker added with UID: " + id);
                SetOptionFiltered(oFiltered);
                SetOptionFilterSampleRate(oSampleRate);
                SetOptionFilterCutoffFreq(oCutOffFreq);
                SetOptionUseContPoseEst(oUseContPoseEst);
                SetOptionConfCutOff(oConfCutOff);
                SetOptionMinSubMarkers(oMinSubMarkers);
                SetOptionMinConfMatrix(oMinConfSubMatrix);
                SetOptionMinConfPattern(oMinConfSubPattern);
                RetrieveMarkerInformation();
            }
            else
            {
                Debug.Log(TAG + ": Marker not able to add with configuration:\n" + str);
            }
        }
        else
        {
            Debug.Log(TAG + ": AddMarker() unsupported status");
        }
    }
    /// <summary>
    /// TODO: correctly shutdown the controller and free resources
    /// </summary>
    //public void RemoveAllMarkers() {
    //    ARUWP.aruwpRemoveAllMarkers();
    //    markers.Clear();
    //}
    //public bool stopRunning() {
    //    if (state == State.WAITING_FOR_FRAME || state == State.DETECTION_RUNNING) {
    //        bool ret = ARUWP.aruwpStopRunning();
    //        if (ret) {
    //            state = State.BASE_INITIALISED;
    //            return true;
    //        }
    //        else {
    //            Debug.Log(TAG + ": stopRunning() fails");
    //            return false;
    //        }
    //    }
    //    else {
    //        Debug.Log(TAG + ": stopRunning() fails unless current status is WAITING_FOR_FRAME or DETECTION_RUNNING");
    //        return false;
    //    }
    //}    //public bool shutDownAR() {
    //    bool ret = ARUWP.aruwpShutdownAR();
    //    if (ret) {
    //        state = State.NOTHING_INITIALISED;
    //        return true;
    //    }
    //    else {
    //        Debug.Log(TAG + ": shutDownAR() fails");
    //        return false;
    //    }
    //}
    //private void OnDestroy() {
    //    removeAllMarkers();
    //    shutDownAR();
    //    ARUWP.aruwpRegisterLogCallback(null);
    //}


    #region setters when access is granted


    /// <summary>
    /// Log the version of ARToolKit using Debug.Log(). [internal use]
    /// </summary>
    private void LogVersionString()
    {
        if (HasNativeHandle())
        {
            StringBuilder buffer = new StringBuilder(20);
            ARUWP.aruwpGetARToolKitVersion(buffer, 20);
            Debug.Log(TAG + ": Version String: " + buffer.ToString());
        }
        else
        {
            Debug.Log(TAG + ": LogVersionString() unsupported status");
        }
    }
Beispiel #10
0
 public static void aruwpRegisterLogCallback(LogCallback lcb)
 {
     if (lcb != null)
     {
         logCallback    = lcb;
         logCallbackGCH = GCHandle.Alloc(logCallback); // Does not need to be pinned, see http://stackoverflow.com/a/19866119/316487
     }
     ARUWP.aruwpRegisterLogCallback(logCallback);
     if (lcb == null)
     {
         logCallback = null;
         logCallbackGCH.Free();
     }
 }
    public bool shutDownAR()
    {
        bool ret = ARUWP.aruwpShutdownAR();

        if (ret)
        {
            state = State.NOTHING_INITIALISED;
            return(true);
        }
        else
        {
            Debug.Log(TAG + ": shutDownAR() fails");
            return(false);
        }
    }
Beispiel #12
0
 /// <summary>
 /// Set matrixCodeType parameter at runtime. [public use]
 /// </summary>
 /// <param name="o">New parameter</param>
 public void SetMatrixCodeType(MatrixCodeType o)
 {
     if (HasNativeHandle())
     {
         ARUWP.aruwpSetMatrixCodeType((int)o);
         matrixCodeType = (MatrixCodeType)ARUWP.aruwpGetMatrixCodeType();
         if (matrixCodeType != o)
         {
             Debug.Log(TAG + ": Unable to set matrix code type to " + o);
         }
     }
     else
     {
         Debug.Log(TAG + ": SetMatrixCodeType() unsupported status");
     }
 }
Beispiel #13
0
 /// <summary>
 /// Set borderSize parameter at runtime. [public use]
 /// </summary>
 /// <param name="o">New parameter</param>
 public void SetBorderSize(float o)
 {
     if (HasNativeHandle())
     {
         ARUWP.aruwpSetBorderSize(o);
         borderSize = ARUWP.aruwpGetBorderSize();
         if (borderSize != o)
         {
             Debug.Log(TAG + ": Unable to set border size to " + o);
         }
     }
     else
     {
         Debug.Log(TAG + ": SetBorderSize() unsupported status");
     }
 }
Beispiel #14
0
 /// <summary>
 /// Set patternDetectionMode parameter at runtime. [public use]
 /// </summary>
 /// <param name="o">New parameter</param>
 public void SetPatternDetectionMode(PatternDetectionMode o)
 {
     if (HasNativeHandle())
     {
         ARUWP.aruwpSetPatternDetectionMode((int)o);
         patternDetectionMode = (PatternDetectionMode)ARUWP.aruwpGetPatternDetectionMode();
         if (patternDetectionMode != o)
         {
             Debug.Log(TAG + ": Unable to set pattern detection mode to " + o);
         }
     }
     else
     {
         Debug.Log(TAG + ": SetPatternDetectionMode() unsupported status");
     }
 }
Beispiel #15
0
 /// <summary>
 /// Set labelingMode parameter at runtime. [public use]
 /// </summary>
 /// <param name="o">New parameter</param>
 public void SetLabelingMode(LabelingMode o)
 {
     if (HasNativeHandle())
     {
         ARUWP.aruwpSetLabelingMode((int)o);
         labelingMode = (LabelingMode)ARUWP.aruwpGetLabelingMode();
         if (labelingMode != o)
         {
             Debug.Log(TAG + ": Unable to set labeling mode to " + o);
         }
     }
     else
     {
         Debug.Log(TAG + ": SetLabelingMode() unsupported status");
     }
 }
Beispiel #16
0
 /// <summary>
 /// Set thresholdMode parameter at runtime. [public use]
 /// </summary>
 /// <param name="o">New parameter</param>
 public void SetVideoThresholdMode(ThresholdMode o)
 {
     if (HasNativeHandle())
     {
         ARUWP.aruwpSetVideoThresholdMode((int)o);
         thresholdMode = (ThresholdMode)ARUWP.aruwpGetVideoThresholdMode();
         if (thresholdMode != o)
         {
             Debug.Log(TAG + ": Unable to set video threshold mode to " + o);
         }
     }
     else
     {
         Debug.Log(TAG + ": SetVideoThresholdMode() unsupported status");
     }
 }
Beispiel #17
0
 /// <summary>
 /// Set threshold parameter at runtime. [public use]
 /// </summary>
 /// <param name="o">New parameter</param>
 public void SetVideoThreshold(int o)
 {
     if (HasNativeHandle())
     {
         ARUWP.aruwpSetVideoThreshold(o);
         threshold = ARUWP.aruwpGetVideoThreshold();
         if (threshold != o)
         {
             Debug.Log(TAG + ": Unable to set video threshold to " + o);
         }
     }
     else
     {
         Debug.Log(TAG + ": SetVideoThreshold() unsupported status");
     }
 }
Beispiel #18
0
 public void setOptionFilterCutoffFreq(float o)
 {
     if (id != -1 && oFiltered == true)
     {
         ARUWP.aruwpSetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_FILTER_CUTOFF_FREQ, o);
         oCutOffFreq = ARUWP.aruwpGetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_FILTER_CUTOFF_FREQ);
         if (oCutOffFreq != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_FILTER_CUTOFF_FREQ to " + o);
         }
     }
     else
     {
         oCutOffFreq = o;
     }
 }
 public void setMatrixCodeType(MatrixCodeType o)
 {
     if (state == State.DETECTION_RUNNING)
     {
         ARUWP.aruwpSetMatrixCodeType((int)o);
         matrixCodeType = (MatrixCodeType)ARUWP.aruwpGetMatrixCodeType();
         if (matrixCodeType != o)
         {
             Debug.Log(TAG + ": Unable to set matrix code type to " + o);
         }
     }
     else
     {
         matrixCodeType = o;
     }
 }
Beispiel #20
0
 public void setOptionFiltered(bool o)
 {
     if (id != -1)
     {
         ARUWP.aruwpSetMarkerOptionBool(id, ARUWP.ARUWP_MARKER_OPTION_FILTERED, o ? 1 : 0);
         oFiltered = ARUWP.aruwpGetMarkerOptionBool(id, ARUWP.ARUWP_MARKER_OPTION_FILTERED);
         if (oFiltered != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_FILTERED to " + o);
         }
     }
     else
     {
         oFiltered = o;
     }
 }
Beispiel #21
0
 public void setOptionMinConfPattern(float o)
 {
     if (id != -1 && type == MarkerType.multi)
     {
         ARUWP.aruwpSetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_MULTI_MIN_CONF_PATTERN, o);
         oMinConfSubPattern = ARUWP.aruwpGetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_MULTI_MIN_CONF_PATTERN);
         if (oMinConfSubPattern != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_MULTI_MIN_CONF_PATTERN to " + o);
         }
     }
     else
     {
         oMinConfSubPattern = o;
     }
 }
 public void setBorderSize(float o)
 {
     if (state == State.DETECTION_RUNNING)
     {
         ARUWP.aruwpSetBorderSize(o);
         borderSize = ARUWP.aruwpGetBorderSize();
         if (borderSize != o)
         {
             Debug.Log(TAG + ": Unable to set border size to " + o);
         }
     }
     else
     {
         borderSize = o;
     }
 }
Beispiel #23
0
 public void setOptionMinSubMarkers(int o)
 {
     if (id != -1 && type == MarkerType.multi)
     {
         ARUWP.aruwpSetMarkerOptionInt(id, ARUWP.ARUWP_MARKER_OPTION_MULTI_MIN_SUBMARKERS, o);
         oMinSubMarkers = ARUWP.aruwpGetMarkerOptionInt(id, ARUWP.ARUWP_MARKER_OPTION_MULTI_MIN_SUBMARKERS);
         if (oMinSubMarkers != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_MULTI_MIN_SUBMARKERS to " + o);
         }
     }
     else
     {
         oMinSubMarkers = o;
     }
 }
Beispiel #24
0
 public void setOptionConfCutOff(float o)
 {
     if (id != -1 && type != MarkerType.multi)
     {
         ARUWP.aruwpSetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_SQUARE_CONFIDENCE_CUTOFF, o);
         oConfCutOff = ARUWP.aruwpGetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_SQUARE_CONFIDENCE_CUTOFF);
         if (oConfCutOff != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_SQUARE_CONFIDENCE_CUTOFF to " + o);
         }
     }
     else
     {
         oConfCutOff = o;
     }
 }
Beispiel #25
0
 public void setOptionUseContPoseEst(bool o)
 {
     if (id != -1 && type != MarkerType.multi)
     {
         ARUWP.aruwpSetMarkerOptionBool(id, ARUWP.ARUWP_MARKER_OPTION_SQUARE_USE_CONT_POSE_ESTIMATION, o? 1:0);
         oUseContPoseEst = ARUWP.aruwpGetMarkerOptionBool(id, ARUWP.ARUWP_MARKER_OPTION_SQUARE_USE_CONT_POSE_ESTIMATION);
         if (oUseContPoseEst != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_SQUARE_USE_CONT_POSE_ESTIMATION to " + o);
         }
     }
     else
     {
         oUseContPoseEst = o;
     }
 }
Beispiel #26
0
 /// <summary>
 /// Set imageProcMode parameter at runtime. [public use]
 /// </summary>
 /// <param name="o">New parameter</param>
 public void SetImageProcMode(ImageProcMode o)
 {
     if (HasNativeHandle())
     {
         ARUWP.aruwpSetImageProcMode((int)o);
         imageProcMode = (ImageProcMode)ARUWP.aruwpGetImageProcMode();
         if (imageProcMode != o)
         {
             Debug.Log(TAG + ": Unable to set image process mode to " + o);
         }
     }
     else
     {
         Debug.Log(TAG + ": SetImageProcMode() unsupported status");
     }
 }
Beispiel #27
0
 /// <summary>
 /// Log the current frame information using Debug.Log(). [internal use]
 /// </summary>
 private void LogFrameInforamtion()
 {
     if (HasNativeHandle())
     {
         int           width, height, pixelSize;
         StringBuilder buffer = new StringBuilder(30);
         ARUWP.aruwpGetFrameParams(out width, out height, out pixelSize, buffer, 30);
         Debug.Log("ARUWP: Frame width and height: " + width + "x" + height);
         Debug.Log("ARUWP: Frame pixel size: " + pixelSize);
         Debug.Log("ARUWP: Frame pixel format string: " + buffer.ToString());
     }
     else
     {
         Debug.Log(TAG + ": LogFrameInforamtion() unsupported status");
     }
 }
Beispiel #28
0
 public void setOptionFilterSampleRate(float o)
 {
     if (id != -1 && oFiltered == true)
     {
         ARUWP.aruwpSetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_FILTER_SAMPLE_RATE, o);
         oSampleRate = ARUWP.aruwpGetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_FILTER_SAMPLE_RATE);
         if (oSampleRate != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_FILTER_SAMPLE_RATE to " + o);
         }
     }
     else
     {
         oSampleRate = o;
     }
 }
Beispiel #29
0
 public void setOptionMinConfMatrix(float o)
 {
     if (id != -1 && type == MarkerType.multi)
     {
         ARUWP.aruwpSetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_MULTI_MIN_CONF_MATRIX, o);
         oMinConfSubMatrix = ARUWP.aruwpGetMarkerOptionFloat(id, ARUWP.ARUWP_MARKER_OPTION_MULTI_MIN_CONF_MATRIX);
         if (oMinConfSubMatrix != o)
         {
             Debug.Log(TAG + ": Unable to set ARUWP_MARKER_OPTION_MULTI_MIN_CONF_MATRIX to " + o);
         }
     }
     else
     {
         oMinConfSubMatrix = o;
     }
 }
 public void setImageProcMode(ImageProcMode o)
 {
     if (state == State.DETECTION_RUNNING)
     {
         ARUWP.aruwpSetImageProcMode((int)o);
         imageProcMode = (ImageProcMode)ARUWP.aruwpGetImageProcMode();
         if (imageProcMode != o)
         {
             Debug.Log(TAG + ": Unable to set image process mode to " + o);
         }
     }
     else
     {
         imageProcMode = o;
     }
 }