public void wasDetected(Detecting m_detecting) { if (!detectorList.Contains(m_detecting)) { detectorList.Add(m_detecting); } }
public void Detect() { Console.WriteLine("De detectielus ziet iets"); //foreach(IDevice device in devices) //{ // device.OnDetect(); //} Detecting?.Invoke(); }
public void Detect() { Console.WriteLine("De detectielus ziet iets"); Detecting?.Invoke(); //foreach(IActivatable device in _devices) //{ // device.Activate(); //} }
private void RunAnalyzer(Detecting detecting, int frameCount, string trimLine) { if (IsAborted || IsErrors) { return; } string script = AviSynthScripting.GetInfoScript(m, AviSynthScripting.ScriptMode.Interlace); int numFrames = 0; if (frameCount > 0) { numFrames = frameCount; } else { try { reader = new AviSynthReader(); reader.ParseScript(script); numFrames = reader.FrameCount; } catch (Exception ex) { if (!IsAborted && num_closes == 0) { IsErrors = true; ErrorText = "SourceDetector (RunAnalyzer): " + ex.Message; StackTrace = ex.StackTrace; Script = script; } } finally { CloseReader(true); } } if (IsAborted || IsErrors) { return; } //Еще настройки int SelectLength = 5; //Длина выборки (5 кадров) int MinAnalyseSections = Settings.SD_Min_Sections; //Мин. кол-во секций для анализа, 150 if (detecting == Detecting.Fields) { //Тут в описании неточность, в оригинале выход скрипта имеет в два раза больше кадров из-за //loop(2), а не из-за SeparateFields. Вместо loop(2) лучше использовать один из уже готовых //клипов с удвоенным кол-вом кадров: atff или abff (без разницы) - декодеру не придется //дважды проходить по одному и тому-же месту (loop(2) - дошли до конца, идем в начало и //начинаем новый проход через весь клип). А если еще вместо DifferenceFromPrevious //использовать DifferenceToNext, то скорость вырастет еще больше! //SelectLength надо тоже установить равным 10-ти, иначе в одной выборке для FieldOrder //будут группы кадров (полей) из двух разных участков видео. //----- // Field order script. For this, we separatefields, so we have twice as many frames anyway // It saves time, and costs nothing to halve the minimum sections to analyse for this example //minAnalyseSections = minAnalyseSections / 2 + 1; // We add one to prevent getting 0; int NewLength = 10; //Длина выборки будет 10 кадров, а мин. кол-во секций пропорционально уменьшаем MinAnalyseSections = (int)Math.Max(MinAnalyseSections / (NewLength / (double)SelectLength), 1); SelectLength = NewLength; } // Check if we need to modify the SelectRangeEvery parameters: int SelectEvery = (int)((100.0 * (double)SelectLength) / AnalysePercent); if (((double)SelectLength * (double)numFrames / (double)SelectEvery) < (int)MinAnalyseSections * SelectLength) { if (numFrames >= MinAnalyseSections * SelectLength) // If there are actually enough frames { SelectEvery = (int)(((double)numFrames / ((double)MinAnalyseSections * (double)SelectLength)) * (double)SelectLength); } else { // if there aren't enough frames, analyse everything -- that's got to be good enough SelectEvery = SelectLength; } } //Имя лог-файла string logFileName = Settings.TempPath + "\\detecting_" + detecting.ToString().ToLower() + ".log"; File.Delete(logFileName); //Прогон скрипта if (detecting == Detecting.Fields) { SetFieldPhase(); } PlayScript(AviSynthScripting.GetSourceDetectionScript(detecting, script, trimLine, logFileName, SelectEvery, SelectLength)); if (IsAborted || IsErrors) { return; } //Определение интерлейса\полей (чтение и анализ лог-файлов) if (detecting == Detecting.Interlace) { AnalyseInterlace(logFileName, SelectEvery, SelectLength, numFrames); } else if (detecting == Detecting.Fields) { AnalyseFields(logFileName, SelectLength); } }
public static string GetSourceDetectionScript(Detecting det, string originalScript, string trimLine, string logFileName, int selectEvery, int selectLength) { //Скрипты для анализа работают намного быстрее, если вместо DifferenceFromPrevious использовать DifferenceToNext. //Не должно сильно сказаться на погрешности, т.к. всё-равно для достоверного определения движения в текущем кадре //нужны оба, и предыдущий, и последующий. Используя только два кадра нельзя определить, какой из них с движением, //а какой статичен. Так-что с FromPrevious всегда будет сколько-то неверно определенных кадров, для которых лучше //было бы использовать ToNext. И наоборот. Зато прибавка в скорости существенная! :) if (det == Detecting.Interlace) //detection return string.Format(InterlaceScript, originalScript, trimLine, logFileName, selectEvery, selectLength, "ToNext"); else if (det == Detecting.Fields) //field order return string.Format(FieldOrderScript, originalScript, trimLine, logFileName, selectEvery, selectLength, "ToNext"); else return null; }
private void RunAnalyzer(Detecting detecting, int frameCount, string trimLine) { if (IsAborted || IsErrors) return; string script = AviSynthScripting.GetInfoScript(m, AviSynthScripting.ScriptMode.Interlace); int numFrames = 0; if (frameCount > 0) numFrames = frameCount; else { try { reader = new AviSynthReader(); reader.ParseScript(script); numFrames = reader.FrameCount; } catch (Exception ex) { if (!IsAborted && num_closes == 0) { IsErrors = true; ErrorText = "SourceDetector (RunAnalyzer): " + ex.Message; StackTrace = ex.StackTrace; Script = script; } } finally { CloseReader(true); } } if (IsAborted || IsErrors) return; //Еще настройки int SelectLength = 5; //Длина выборки (5 кадров) int MinAnalyseSections = Settings.SD_Min_Sections; //Мин. кол-во секций для анализа, 150 if (detecting == Detecting.Fields) { //Тут в описании неточность, в оригинале выход скрипта имеет в два раза больше кадров из-за //loop(2), а не из-за SeparateFields. Вместо loop(2) лучше использовать один из уже готовых //клипов с удвоенным кол-вом кадров: atff или abff (без разницы) - декодеру не придется //дважды проходить по одному и тому-же месту (loop(2) - дошли до конца, идем в начало и //начинаем новый проход через весь клип). А если еще вместо DifferenceFromPrevious //использовать DifferenceToNext, то скорость вырастет еще больше! //SelectLength надо тоже установить равным 10-ти, иначе в одной выборке для FieldOrder //будут группы кадров (полей) из двух разных участков видео. //----- // Field order script. For this, we separatefields, so we have twice as many frames anyway // It saves time, and costs nothing to halve the minimum sections to analyse for this example //minAnalyseSections = minAnalyseSections / 2 + 1; // We add one to prevent getting 0; int NewLength = 10; //Длина выборки будет 10 кадров, а мин. кол-во секций пропорционально уменьшаем MinAnalyseSections = (int)Math.Max(MinAnalyseSections / (NewLength / (double)SelectLength), 1); SelectLength = NewLength; } // Check if we need to modify the SelectRangeEvery parameters: int SelectEvery = (int)((100.0 * (double)SelectLength) / AnalysePercent); if (((double)SelectLength * (double)numFrames / (double)SelectEvery) < (int)MinAnalyseSections * SelectLength) { if (numFrames >= MinAnalyseSections * SelectLength) // If there are actually enough frames { SelectEvery = (int)(((double)numFrames / ((double)MinAnalyseSections * (double)SelectLength)) * (double)SelectLength); } else // if there aren't enough frames, analyse everything -- that's got to be good enough SelectEvery = SelectLength; } //Имя лог-файла string logFileName = Settings.TempPath + "\\detecting_" + detecting.ToString().ToLower() + ".log"; File.Delete(logFileName); //Прогон скрипта if (detecting == Detecting.Fields) SetFieldPhase(); PlayScript(AviSynthScripting.GetSourceDetectionScript(detecting, script, trimLine, logFileName, SelectEvery, SelectLength)); if (IsAborted || IsErrors) return; //Определение интерлейса\полей (чтение и анализ лог-файлов) if (detecting == Detecting.Interlace) AnalyseInterlace(logFileName, SelectEvery, SelectLength, numFrames); else if (detecting == Detecting.Fields) AnalyseFields(logFileName, SelectLength); }
// Use this for initialization void Start() { detecting = gameObject.GetComponent<Detecting>(); SharpUnit.Assert.NotNull(detecting); }
public void wasDetected(Detecting m_detecting) { if(!detectorList.Contains(m_detecting)){ detectorList.Add(m_detecting); } }
// Use this for initialization void Start() { detecting = gameObject.GetComponent <Detecting>(); SharpUnit.Assert.NotNull(detecting); }