예제 #1
0
    // Use this for initialization
    void Start()
    {
        VL_List = new VehicleLocation[MaxNumberOfDetectedVehicles];
        OpenCVVehicleDetector.Initialize(BackgroundThreshold, EnableDebug);
        int i = 0;

        foreach (LivestreamInfo info in LivestreamList)
        {
            int code = OpenCVVehicleDetector.AddLivestream(info.URL, i, info.numOfErosions, info.numOfDilations,
                                                           (int)info.DetectionAreaPoint1.x, (int)info.DetectionAreaPoint1.y, (int)info.DetectionAreaPoint2.x,
                                                           (int)info.DetectionAreaPoint2.y, info.FirstColorThreshold, info.SecondColorThreshold);
            i++;
            if (code == -1)
            {
                Debug.LogError("Failed to connect to: " + info.URL);
            }
        }
        isReady = true;
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        /*if (Timer >= SecondsPerFrame)
         * {
         *  if (isReady)
         *  {
         *      // Get data from the DLL
         *      int NumberOfVehicles = 0;
         *      VL_List = new VehicleLocation[MaxNumberOfDetectedVehicles];
         *      unsafe
         *      {
         *          fixed (VehicleLocation* vlist = VL_List)
         *          {
         *              OpenCVVehicleDetector.Detect(vlist, MaxNumberOfDetectedVehicles, ref NumberOfVehicles);
         *          }
         *      }
         *      if (NumberOfVehicles > 0)
         *          VehicleInstantiator.ParseData(VL_List, NumberOfVehicles);
         *      Timer = 0;
         *  }
         * }
         * else
         *  Timer += Time.deltaTime;*/

        if (isReady)
        {
            // Get data from the DLL
            int NumberOfVehicles = 0;
            VL_List = new VehicleLocation[MaxNumberOfDetectedVehicles];
            unsafe
            {
                fixed(VehicleLocation *vlist = VL_List)
                {
                    OpenCVVehicleDetector.Detect(vlist, MaxNumberOfDetectedVehicles, ref NumberOfVehicles);
                }
            }
            if (NumberOfVehicles > 0)
            {
                VehicleInstantiator.ParseData(VL_List, NumberOfVehicles);
            }
        }
    }
예제 #3
0
 private void OnApplicationQuit()
 {
     isReady = false;
     OpenCVVehicleDetector.CloseAll();
 }