public FeaturesLayer(ref Task task) { _disposed = false; // copy task _task = new Task(task); // init results struct _res = new Results(); _numRunningFeat = 0; // features vars _bitExactThread = null; _bitExact = null; _badContrast = null; _badContrastThread = null; // --------------- // set status to 0 _loadingImagesStatus = 0; _runStatus = 0; // allocate memory for ImageInfo array _images = new ImageInfo[task.ImagePathes.Count]; for(int i=0; i<_images.Length; i++) _images[i] = null; // this will run loading images from run() _loadingImagesThread = null; }
public void TestBitExactLoadPictures() { int numImages = pathes.Length; ImageInfo[] images = new ImageInfo[numImages]; for (int i = 0; i < numImages; i++) images[i] = new ImageInfo(pathes[i]); // int w=24, j=22; BitExact be = new BitExact(images); //be.equalImages(w, j); //Debug.WriteLine("{0} \n {1}", images[w].getPath(), images[j].getPath()); be.run(); Debug.WriteLine("{0}", "OK!!!"); }
private void runFeatures() { if (_task.Features[(int)Feature.BIT_EXACT]) { _bitExact = new BitExact(_images); _bitExactThread = new Thread(_bitExact.run); _bitExactThread.Name = "bitExact"; _bitExactThread.Start(); _numRunningFeat++; } if (_bitExactThread != null) _bitExactThread.Join(); if (_task.Features[(int)Feature.BAD_CONTRAST]) { _badContrast = new BadContrast(_images); _badContrastThread = new Thread(_badContrast.run); _badContrastThread.Start(); _numRunningFeat++; } }
/// <summary> /// will update RunStatus and on completion, will collect results /// </summary> /// <returns></returns> private int updateRunStatus() { int currStatus = 0; if (_bitExact != null) { currStatus += _bitExact.RunStatus/_numRunningFeat; if (_bitExact.RunStatus == 100) { _res.setBitExact(_bitExact.Results); _bitExact = null; _bitExactThread = null; } } if (_badContrast != null) { currStatus += _badContrast.RunStatus / _numRunningFeat; if (_badContrast.RunStatus == 100) { _res.setBadContrast(_badContrast.Results); _badContrast = null; _badContrastThread = null; } } _runStatus = System.Math.Max(currStatus, _runStatus); return _runStatus; }
protected virtual void Dispose(bool disposing) { if (!_disposed) { // clear bitExact bool isLoadingImages = (_loadingImagesThread != null && _loadingImagesThread.IsAlive); if (isLoadingImages) { _loadingImagesThread.Abort(); } else { bool isBitExactRunning = (_bitExact != null && _bitExactThread != null && _bitExactThread.IsAlive); if (isBitExactRunning) { _bitExactThread.Abort(); } _bitExact = null; _bitExactThread = null; } // clear images // assuming that if im[i] is null im[i +..] is null for (int i=0; i< _images.Length; i++) { if (_images[i] != null) { _images[i].Dispose(); _images[i] = null; } else { break; } } _disposed = true; } }