public CapturePathConfiguration()
        {
            string root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            LeftImageRoot  = root;
            RightImageRoot = root;
            LeftVideoRoot  = root;
            RightVideoRoot = root;

            string subdir = @"Kinovea\%year\%year%month\%year%month%day";

            LeftImageSubdir  = subdir;
            LeftVideoSubdir  = subdir;
            RightImageSubdir = subdir;
            RightVideoSubdir = subdir;

            string file = @"%year%month%day-%hour%minute%second";

            LeftImageFile  = file;
            LeftVideoFile  = file;
            RightImageFile = file;
            RightVideoFile = file;

            ImageFormat = KinoveaImageFormat.JPG;
            VideoFormat = KinoveaVideoFormat.MP4;
        }
Example #2
0
 private void ImportPreferences()
 {
     m_ImageDirectory = m_prefManager.CaptureImageDirectory;
     m_VideoDirectory = m_prefManager.CaptureVideoDirectory;
     m_ImageFormat    = m_prefManager.CaptureImageFormat;
     m_VideoFormat    = m_prefManager.CaptureVideoFormat;
     m_bUsePattern    = m_prefManager.CaptureUsePattern;
     m_Pattern        = m_prefManager.CapturePattern;
     m_iCounter       = m_prefManager.CaptureImageCounter;       // Use the image counter for sample.
     m_iMemoryBuffer  = m_prefManager.CaptureMemoryBuffer;
 }
Example #3
0
        private KinoveaVideoFormat ParseVideoFormat(string _format)
        {
            KinoveaVideoFormat output = KinoveaVideoFormat.MKV;

            try
            {
                output = (KinoveaVideoFormat)Enum.Parse(KinoveaVideoFormat.MKV.GetType(), _format);
            }
            catch (Exception)
            {
                log.ErrorFormat("Video format parsing failed. Use default value");
            }

            return(output);
        }
Example #4
0
        public static KinoveaVideoFormat GetVideoFormat(string filename)
        {
            KinoveaVideoFormat format    = KinoveaVideoFormat.MKV;
            string             extension = Path.GetExtension(filename).ToLower();

            if (extension == ".mkv")
            {
                format = KinoveaVideoFormat.MKV;
            }
            else if (extension == ".mp4")
            {
                format = KinoveaVideoFormat.MP4;
            }
            else if (extension == ".avi")
            {
                format = KinoveaVideoFormat.AVI;
            }

            return(format);
        }
Example #5
0
        public static int GetFilterIndex(string filter, KinoveaVideoFormat format)
        {
            int defaultIndex = 1;

            if (string.IsNullOrEmpty(filter))
            {
                return(defaultIndex);
            }

            string[] splits = filter.Split('|');
            if (splits.Length < 2 || splits.Length % 2 != 0)
            {
                return(defaultIndex);
            }

            Dictionary <KinoveaVideoFormat, int> mapping = new Dictionary <KinoveaVideoFormat, int>();

            for (int i = 1; i < splits.Length; i += 2)
            {
                // Filter index is 1-based.
                int index = ((i - 1) / 2) + 1;

                if (splits[i].Contains("*.mkv"))
                {
                    mapping.Add(KinoveaVideoFormat.MKV, index);
                }
                else if (splits[i].Contains("*.avi"))
                {
                    mapping.Add(KinoveaVideoFormat.AVI, index);
                }
                else if (splits[i].Contains("*.mp4"))
                {
                    mapping.Add(KinoveaVideoFormat.MP4, index);
                }
            }

            return(mapping.ContainsKey(format) ? mapping[format] : defaultIndex);
        }
Example #6
0
        private void ParseConfigFile(string filePath)
        {
            // Fill the local variables with infos found in the XML file.
            XmlReader PreferencesReader = new XmlTextReader(filePath);

            if (PreferencesReader != null)
            {
                try
                {
                    while (PreferencesReader.Read())
                    {
                        if ((PreferencesReader.IsStartElement()) && (PreferencesReader.Name == "KinoveaPreferences"))
                        {
                            while (PreferencesReader.Read())
                            {
                                if (PreferencesReader.IsStartElement())
                                {
                                    switch (PreferencesReader.Name)
                                    {
                                    case "HistoryCount":
                                        m_iFilesToSave = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Language":
                                        m_UICultureName = PreferencesReader.ReadString();
                                        break;

                                    case "TimeCodeFormat":
                                        m_TimeCodeFormat = ParseTimeCodeFormat(PreferencesReader.ReadString());
                                        break;

                                    case "SpeedUnit":
                                        m_SpeedUnit = ParseSpeedUnit(PreferencesReader.ReadString());
                                        break;

                                    case "ImageAspectRatio":
                                        m_AspectRatio = ParseImageAspectRatio(PreferencesReader.ReadString());
                                        break;

                                    case "DeinterlaceByDefault":
                                        m_bDeinterlaceByDefault = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "WorkingZoneSeconds":
                                        m_iWorkingZoneSeconds = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "WorkingZoneMemory":
                                        m_iWorkingZoneMemory = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "InfosFading":
                                        //m_DefaultFading.ReadXml(PreferencesReader);
                                        break;

                                    case "MaxFading":
                                        m_iMaxFading = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "DrawOnPlay":
                                        m_bDrawOnPlay = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerThumbnailsSize":
                                        m_iExplorerThumbsSize = (ExplorerThumbSizes)ExplorerThumbSizes.Parse(m_iExplorerThumbsSize.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerVisible":
                                        m_bIsExplorerVisible = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerSplitterDistance":
                                        m_iExplorerSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ActiveFileBrowserTab":
                                        m_ActiveFileBrowserTab = (ActiveFileBrowserTab)ActiveFileBrowserTab.Parse(m_ActiveFileBrowserTab.GetType(), PreferencesReader.ReadString());
                                        break;

                                    case "ExplorerFilesSplitterDistance":
                                        m_iExplorerFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "ShortcutsFilesSplitterDistance":
                                        m_iShortcutsFilesSplitterDistance = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "Shortcuts":
                                        ParseShortcuts(PreferencesReader);
                                        break;

                                    case "RecentColors":
                                        ParseRecentColors(PreferencesReader);
                                        break;

                                    case "CaptureImageDirectory":
                                        m_CaptureImageDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureImageFile":
                                        m_CaptureImageFile = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureVideoDirectory":
                                        m_CaptureVideoDirectory = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureVideoFile":
                                        m_CaptureVideoFile = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureImageFormat":
                                        m_CaptureImageFormat = ParseImageFormat(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureVideoFormat":
                                        m_CaptureVideoFormat = ParseVideoFormat(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureUsePattern":
                                        m_bCaptureUsePattern = bool.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "CapturePattern":
                                        m_CapturePattern = PreferencesReader.ReadString();
                                        break;

                                    case "CaptureImageCounter":
                                        m_iCaptureImageCounter = long.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureVideoCounter":
                                        m_iCaptureVideoCounter = long.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "CaptureMemoryBuffer":
                                        m_iCaptureMemoryBuffer = int.Parse(PreferencesReader.ReadString());
                                        break;

                                    case "DeviceConfigurations":
                                        ParseDeviceConfigurations(PreferencesReader);
                                        break;

                                    case "NetworkCameraUrl":
                                        m_NetworkCameraUrl = PreferencesReader.ReadString();
                                        break;

                                    case "NetworkCameraFormat":
                                        m_NetworkCameraFormat = ParseCameraFormat(PreferencesReader.ReadString());
                                        break;

                                    case "RecentNetworkCameras":
                                        ParseRecentCameras(PreferencesReader);
                                        break;

                                    default:
                                        // Preference from a newer file format...
                                        // We don't have a holder variable for it.
                                        break;
                                    }
                                }
                                else if (PreferencesReader.Name == "KinoveaPreferences")
                                {
                                    break;
                                }
                                else
                                {
                                    // Fermeture d'un tag interne.
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    log.Error("Error happenned while parsing preferences. We'll keep the default values.");
                }
                finally
                {
                    PreferencesReader.Close();
                }
            }
        }
Example #7
0
        public void ReadXML(XmlReader reader)
        {
            reader.ReadStartElement();

            while (reader.NodeType == XmlNodeType.Element)
            {
                switch (reader.Name)
                {
                case "TimecodeFormat":
                    timecodeFormat = (TimecodeFormat)Enum.Parse(typeof(TimecodeFormat), reader.ReadElementContentAsString());
                    break;

                case "SpeedUnit":
                    speedUnit = (SpeedUnit)Enum.Parse(typeof(SpeedUnit), reader.ReadElementContentAsString());
                    break;

                case "AccelerationUnit":
                    accelerationUnit = (AccelerationUnit)Enum.Parse(typeof(AccelerationUnit), reader.ReadElementContentAsString());
                    break;

                case "AngleUnit":
                    angleUnit = (AngleUnit)Enum.Parse(typeof(AngleUnit), reader.ReadElementContentAsString());
                    break;

                case "AngularVelocityUnit":
                    angularVelocityUnit = (AngularVelocityUnit)Enum.Parse(typeof(AngularVelocityUnit), reader.ReadElementContentAsString());
                    break;

                case "AngularAccelerationUnit":
                    angularAccelerationUnit = (AngularAccelerationUnit)Enum.Parse(typeof(AngularAccelerationUnit), reader.ReadElementContentAsString());
                    break;

                case "CustomLengthUnit":
                    customLengthUnit = reader.ReadElementContentAsString();
                    break;

                case "CustomLengthAbbreviation":
                    customLengthAbbreviation = reader.ReadElementContentAsString();
                    break;

                case "AspectRatio":
                    aspectRatio = (ImageAspectRatio)Enum.Parse(typeof(ImageAspectRatio), reader.ReadElementContentAsString());
                    break;

                case "DeinterlaceByDefault":
                    deinterlaceByDefault = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "InteractiveFrameTracker":
                    interactiveFrameTracker = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "WorkingZoneSeconds":
                    workingZoneSeconds = reader.ReadElementContentAsInt();
                    break;

                case "WorkingZoneMemory":
                    workingZoneMemory = reader.ReadElementContentAsInt();
                    break;

                case "SyncLockSpeed":
                    syncLockSpeed = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "ImageFormat":
                    imageFormat = (KinoveaImageFormat)Enum.Parse(typeof(KinoveaImageFormat), reader.ReadElementContentAsString());
                    break;

                case "VideoFormat":
                    videoFormat = (KinoveaVideoFormat)Enum.Parse(typeof(KinoveaVideoFormat), reader.ReadElementContentAsString());
                    break;

                case "InfoFading":
                    defaultFading.ReadXml(reader);
                    break;

                case "MaxFading":
                    maxFading = reader.ReadElementContentAsInt();
                    break;

                case "DrawOnPlay":
                    drawOnPlay = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "RecentColors":
                    ParseRecentColors(reader);
                    break;

                case "MaxRecentColors":
                    maxRecentColors = reader.ReadElementContentAsInt();
                    break;

                case "TrackingProfile":
                    trackingProfile.ReadXml(reader);
                    break;

                case "EnableFiltering":
                    enableFiltering = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                case "EnableCustomToolsDebugMode":
                    enableCustomToolsDebugMode = XmlHelper.ParseBoolean(reader.ReadElementContentAsString());
                    break;

                default:
                    reader.ReadOuterXml();
                    break;
                }
            }

            reader.ReadEndElement();
        }
Example #8
0
 private void cmbVideoFormat_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_VideoFormat = (KinoveaVideoFormat)cmbVideoFormat.SelectedIndex;
 }
        public void ReadXml(XmlReader r)
        {
            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                switch (r.Name)
                {
                case "LeftImageRoot":
                    LeftImageRoot = r.ReadElementContentAsString();
                    break;

                case "LeftImageSubdir":
                    LeftImageSubdir = r.ReadElementContentAsString();
                    break;

                case "LeftImageFile":
                    LeftImageFile = r.ReadElementContentAsString();
                    break;

                case "LeftVideoRoot":
                    LeftVideoRoot = r.ReadElementContentAsString();
                    break;

                case "LeftVideoSubdir":
                    LeftVideoSubdir = r.ReadElementContentAsString();
                    break;

                case "LeftVideoFile":
                    LeftVideoFile = r.ReadElementContentAsString();
                    break;

                case "RightImageRoot":
                    RightImageRoot = r.ReadElementContentAsString();
                    break;

                case "RightImageSubdir":
                    RightImageSubdir = r.ReadElementContentAsString();
                    break;

                case "RightImageFile":
                    RightImageFile = r.ReadElementContentAsString();
                    break;

                case "RightVideoRoot":
                    RightVideoRoot = r.ReadElementContentAsString();
                    break;

                case "RightVideoSubdir":
                    RightVideoSubdir = r.ReadElementContentAsString();
                    break;

                case "RightVideoFile":
                    RightVideoFile = r.ReadElementContentAsString();
                    break;

                case "ImageFormat":
                    ImageFormat = (KinoveaImageFormat)Enum.Parse(typeof(KinoveaImageFormat), r.ReadElementContentAsString());
                    break;

                case "VideoFormat":
                    VideoFormat = (KinoveaVideoFormat)Enum.Parse(typeof(KinoveaVideoFormat), r.ReadElementContentAsString());
                    break;

                default:
                    string outerXml = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in XML: {0}", outerXml);
                    break;
                }
            }

            r.ReadEndElement();
        }