Пример #1
0
    protected override void DoCreate()
    {
        base.DoCreate();

        cameraImageDrawer_ = new smartar.CameraImageDrawer(smart_);
        sensorDevice_      = new smartar.SensorDevice(smart_);
        screenDevice_      = new smartar.ScreenDevice(smart_);

        smartar.SensorDeviceInfo sensorInfo = new smartar.SensorDeviceInfo();
        sensorDevice_.GetDeviceInfo(sensorInfo);
        recognizer_.SetSensorDeviceInfo(sensorInfo);

        CreateParam param;

        param.smart_             = smart_.self_;
        param.recognizer_        = recognizer_.self_;
        param.sensorDevice_      = sensorDevice_.self_;
        param.screenDevice_      = screenDevice_.self_;
        param.cameraImageDrawer_ = cameraImageDrawer_.self_;
        self_ = sarSmartar_SarSmartARController_sarDoCreate(ref param, numWorkerThreads_ > 0);

        if (self_ != IntPtr.Zero)
        {
            // Start worker threads
            if (numWorkerThreads_ > 0)
            {
                workerThreads_ = new Thread[numWorkerThreads_];
                for (int i = 0; i < numWorkerThreads_; ++i)
                {
                    Thread thread = new Thread(() => {
                        sarSmartar_SarSmartARController_sarRunWorkerThread(self_);
                    });
                    thread.Start();
                    workerThreads_[i] = thread;
                }
            }
            else
            {
                workerThreads_ = null;
            }

            started_ = true;
        }
    }
Пример #2
0
 protected override void DoDestroy()
 {
     // Finish worker threads
     if (numWorkerThreads_ > 0)
     {
         if (self_ != IntPtr.Zero)
         {
             sarSmartar_SarSmartARController_sarFinishWorkerThread(self_);
         }
         for (int i = 0; i < numWorkerThreads_; ++i)
         {
             workerThreads_[i].Join();
         }
     }
     if (self_ != IntPtr.Zero)
     {
         sarSmartar_SarSmartARController_sarDoDestroy(self_);
         self_ = IntPtr.Zero;
     }
     if (screenDevice_ != null)
     {
         screenDevice_.Dispose();
         screenDevice_ = null;
     }
     if (sensorDevice_ != null)
     {
         sensorDevice_.Dispose();
         sensorDevice_ = null;
     }
     if (cameraImageDrawer_ != null)
     {
         cameraImageDrawer_.Dispose();
         cameraImageDrawer_ = null;
     }
     base.DoDestroy();
 }