Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud Handler #3

Open
CT-1326 opened this issue Mar 28, 2020 · 1 comment
Open

Cloud Handler #3

CT-1326 opened this issue Mar 28, 2020 · 1 comment
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@CT-1326
Copy link

CT-1326 commented Mar 28, 2020


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;

public class SimpleCloudHandler : MonoBehaviour, IObjectRecoEventHandler {
    public ImageTargetBehaviour ImageTargetTemplate;
    private CloudRecoBehaviour mCloudRecoBehaviour; 
    private bool mIsScanning = false; 
    public static string mTargetMetadata = ""; 
// Use this for initialization 
    void Start () { 
// register this event handler at the cloud reco behaviour 
        mCloudRecoBehaviour = GetComponent(); 
  
        if (mCloudRecoBehaviour) 
        { 
            mCloudRecoBehaviour.RegisterEventHandler(this); 
        } 
    }
    public void OnInitialized(TargetFinder targetFinder) {
        Debug.Log ("Cloud Reco initialized");
    }
    public void OnInitError(TargetFinder.InitState initError) {
        Debug.Log ("Cloud Reco init error " + initError.ToString());
    }
    public void OnUpdateError(TargetFinder.UpdateState updateError) {
        Debug.Log ("Cloud Reco update error " + updateError.ToString());
    }
    public void OnStateChanged(bool scanning) {
        mIsScanning = scanning;
        if (scanning)
        {
            // clear all known trackables
            var tracker = TrackerManager.Instance.GetTracker();
            tracker.GetTargetFinder().ClearTrackables(false);
        }
    }
    // Here we handle a cloud target recognition event
    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult) {
        TargetFinder.CloudRecoSearchResult cloudRecoSearchResult = 
            (TargetFinder.CloudRecoSearchResult)targetSearchResult;
        // do something with the target metadata
        mTargetMetadata = cloudRecoSearchResult.MetaData;
        // stop the target finder (i.e. stop scanning the cloud)
        mCloudRecoBehaviour.CloudRecoEnabled = false;
        // Build augmentation based on target 
        if (ImageTargetTemplate) { 
            // enable the new result with the same ImageTargetBehaviour: 
            ObjectTracker tracker = TrackerManager.Instance.GetTracker(); 
            tracker.GetTargetFinder().EnableTracking(targetSearchResult, ImageTargetTemplate.gameObject);
            Debug.Log(mTargetMetadata);
        }
    }
    void OnGUI() {
        GUIStyle style = new GUIStyle(GUI.skin.button);
        style.fontSize = 30;
        // Display current 'scanning' status
        // GUI.Box (new Rect(100,100,200,50), mIsScanning ? "Scanning" : "Not scanning");
        // // Display metadata of latest detected cloud-target
        // GUI.Box (new Rect(100,200,200,50), "Metadata: " + mTargetMetadata);
        // If not scanning, show button
        // so that user can restart cloud scanning
        if (!mIsScanning) {
            if (GUI.Button(new Rect(100,300,300,150), "Restart Scanning",style)) {
            // Restart TargetFinder
            mCloudRecoBehaviour.CloudRecoEnabled = true;
            }
        }
    }
}

@CT-1326 CT-1326 added documentation Improvements or additions to documentation good first issue Good for newcomers labels Mar 28, 2020
@CT-1326
Copy link
Author

CT-1326 commented Apr 3, 2020

클라우드 DB에 저장된 이미지 인식 관련 이벤트들을 발생시켜주는 스크립트

인식 전과 후로 나누어 이벤트를 발생시킴

@CT-1326 CT-1326 removed the good first issue Good for newcomers label Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants