示例#1
0
            //List<Classifier.Recognition> mappedRecognitions
            public void onRecoginizeSuccess(AndroidJavaObject list)
            {
                if (!_RecognizeApi.IsRunning())
                {
                    return;
                }

                int size = list.Call <int>("size");
                List <Recognition> dataList = new List <Recognition>(size);

                for (int i = 0; i < size; i++)
                {
                    Recognition       rec  = new Recognition();
                    AndroidJavaObject item = list.Call <AndroidJavaObject>("get", i);
                    rec.id    = item.Call <string>("getId");
                    rec.title = item.Call <string>("getTitle");
                    AndroidJavaObject confidenceObject = item.Call <AndroidJavaObject>("getConfidence");
                    rec.confidence = ((int)(confidenceObject.Call <float>("floatValue") * 100)) / 100.00f;
                    AndroidJavaObject locationObject = item.Call <AndroidJavaObject>("getLocation");
                    float             cx             = locationObject.Call <float>("centerX");
                    float             cy             = locationObject.Call <float>("centerY");
                    float             width          = locationObject.Call <float>("width");
                    float             height         = locationObject.Call <float>("height");
                    rec.frameWidth  = item.Call <int>("getPreviewWidth");
                    rec.frameHeight = item.Call <int>("getPreviewHeight");
                    Rect rect = new Rect(cx - width / 2, cy - height / 2, width, height);
                    rec.location = rect;

                    // LOG
                    // rec.PrintInfo();

                    dataList.Add(rec);

                    Loom.QueueOnMainThread((param) =>
                    {
                        if (_OnRecognizeSuccess != null)
                        {
                            _OnRecognizeSuccess((List <Recognition>)param);
                        }
                    }, dataList);
                }
            }
示例#2
0
            public void onSensorDataChanged(AndroidJavaObject sensorEventObject)
            {
                float             x              = sensorEventObject.Get <float>("x");
                float             y              = sensorEventObject.Get <float>("y");
                float             z              = sensorEventObject.Get <float>("z");
                long              timestamp      = sensorEventObject.Get <long>("timestamp");
                AndroidJavaObject locationObject = sensorEventObject.Get <AndroidJavaObject>("sensorLocation");
                AndroidJavaObject typeObject     = sensorEventObject.Get <AndroidJavaObject>("sensorType");
                SENSOR_LOCATION   sensorLocation = (SENSOR_LOCATION)locationObject.Call <int>("ordinal");
                SENSOR_TYPE       sensorType     = (SENSOR_TYPE)typeObject.Call <int>("ordinal");

                NibiruSensorEvent sensorEvent = new NibiruSensorEvent(x, y, z, timestamp, sensorType, sensorLocation);

                // sensorEvent.printLog();

                // 用Loom的方法在Unity主线程中调用Text组件
                Loom.QueueOnMainThread((param) =>
                {
                    if (OnSensorDataChangedHandler != null)
                    {
                        OnSensorDataChangedHandler((NibiruSensorEvent)param);
                    }
                }, sensorEvent);
            }
示例#3
0
 public void CalibrationDelay()
 {
     Loom.QueueOnMainThread((param) => { Calibration(); }, true);
 }
示例#4
0
 void Awake()
 {
     _current    = this;
     initialized = true;
 }