コード例 #1
0
ファイル: Service.cs プロジェクト: dalinhuang/appcollection
        public string[] SearchFaces(int cameraID, DateTime beginTime, DateTime endTime)
        {
            ImageDirSys start =
                new ImageDirSys(cameraID.ToString("d2"), DateTimeInString.FromDateTime(beginTime));
            ImageDirSys end =
                 new ImageDirSys(cameraID.ToString("d2"), DateTimeInString.FromDateTime(endTime));

            FaceFiles = ImageSearch.SearchImages(start, end, ImageDirSys.SearchType.PicType);

            return FaceFiles;
        }
コード例 #2
0
        private void queryBtn_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            ClearLists();

            if (this.comboBox1.Text == "" || this.comboBox1.Text == null)
            {
                MessageBox.Show("请选择要查询的摄像头ID", "警告");
                return;
            }
            string cameraID = int.Parse(this.comboBox1.Text).ToString("D2");

            //judge the input validation
            DateTime date1 = this.dateTimePicker1.Value;
            DateTime date2 = this.dateTimePicker2.Value;
            DateTime time1 = this.timeEdit1.Time;
            DateTime time2 = this.timeEdit2.Time;

            DateTime dateTime1 = new DateTime(date1.Year, date1.Month, date1.Day, time1.Hour, time1.Minute, time1.Second);
            DateTime dateTime2 = new DateTime(date2.Year, date2.Month, date2.Day, time2.Hour, time2.Minute, time2.Second);
            if (dateTime1 >= dateTime2)
            {
                MessageBox.Show("时间起点不应该大于或者等于时间终点,请重新输入!", "警告");
                return;
            }
            /////
            DateTimeInString dtString1 = DateTimeInString.FromDateTime(dateTime1);

            DateTimeInString dtString2 = DateTimeInString.FromDateTime(dateTime2);

            Query.ImageDirSys startDir = new ImageDirSys(cameraID, dtString1);
            Query.ImageDirSys endDir = new ImageDirSys(cameraID, dtString2);

            imagesFound = ImageSearch.SearchImages(startDir, endDir, RemoteImaging.Query.ImageDirSys.SearchType.PicType);

            if (imagesFound.Length == 0)
            {
                MessageBox.Show(this, "未找到图片");
                return;
            }

            CalcPagesCount();
            currentPage = 1;
            UpdatePagesLabel();

            if (imagesFound == null)
            {
                MessageBox.Show("没有搜索到满足条件的图片!", "警告");
                return;
            }

            this.bestPicListView.Scrollable = true;
            this.bestPicListView.MultiSelect = false;
            this.bestPicListView.View = View.LargeIcon;
            this.bestPicListView.LargeImageList = imageList1;

            ShowCurrentPage();

            Cursor.Current = Cursors.Default;
        }
コード例 #3
0
        private void queryBtn_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            ClearLists();

            if (this.comboBox1.Text == "" || this.comboBox1.Text == null)
            {
                MessageBox.Show("请选择要查询的摄像头ID", "警告");
                return;
            }
            string cameraID = int.Parse(this.comboBox1.Text).ToString("D2");


            //judge the input validation
            DateTime date1 = this.dateTimePicker1.Value;
            DateTime date2 = this.dateTimePicker2.Value;
            DateTime time1 = this.timeEdit1.Time;
            DateTime time2 = this.timeEdit2.Time;

            DateTime dateTime1 = new DateTime(date1.Year, date1.Month, date1.Day, time1.Hour, time1.Minute, time1.Second);
            DateTime dateTime2 = new DateTime(date2.Year, date2.Month, date2.Day, time2.Hour, time2.Minute, time2.Second);

            if (dateTime1 >= dateTime2)
            {
                MessageBox.Show("时间起点不应该大于或者等于时间终点,请重新输入!", "警告");
                return;
            }
            /////
            DateTimeInString dtString1 = DateTimeInString.FromDateTime(dateTime1);

            DateTimeInString dtString2 = DateTimeInString.FromDateTime(dateTime2);

            Query.ImageDirSys startDir = new ImageDirSys(cameraID, dtString1);
            Query.ImageDirSys endDir   = new ImageDirSys(cameraID, dtString2);

            imagesFound = ImageSearch.SearchImages(startDir, endDir, RemoteImaging.Query.ImageDirSys.SearchType.PicType);

            if (imagesFound.Length == 0)
            {
                MessageBox.Show(this, "未找到图片");
                return;
            }


            CalcPagesCount();
            currentPage = 1;
            UpdatePagesLabel();


            if (imagesFound == null)
            {
                MessageBox.Show("没有搜索到满足条件的图片!", "警告");
                return;
            }

            this.bestPicListView.Scrollable     = true;
            this.bestPicListView.MultiSelect    = false;
            this.bestPicListView.View           = View.LargeIcon;
            this.bestPicListView.LargeImageList = imageList1;


            ShowCurrentPage();

            Cursor.Current = Cursors.Default;
        }
コード例 #4
0
        public string[] SearchImages(ImageDirSys startDir, ImageDirSys endDir, ImageDirSys.SearchType searchType)
        {
            int startYear = int.Parse(startDir.Year);
            int startMonth = int.Parse(startDir.Month);
            int startDay = int.Parse(startDir.Day);
            int startHour = int.Parse(startDir.Hour);
            int startMinute = int.Parse(startDir.Minute);
            int startSecond = int.Parse(startDir.Second);
            int endYear = int.Parse(endDir.Year);
            int endMonth = int.Parse(endDir.Month);
            int endDay = int.Parse(endDir.Day);
            int endHour = int.Parse(endDir.Hour);
            int endMinute = int.Parse(endDir.Minute);
            int endSecond = int.Parse(endDir.Second);

            string beginDir = ImageDirSys.BeginDir;
            string subSearchPath = "";
            if (searchType == ImageDirSys.SearchType.PicType)
            {
                subSearchPath = Query.ImageDirSys.IconPath;
            }
            else if (searchType == ImageDirSys.SearchType.VideoType)
            {
                subSearchPath = Query.ImageDirSys.VideoPath;
            }

            ArrayList fileList = new ArrayList();

            if (startYear == endYear &&
                startMonth == endMonth &&
                startDay == endDay)//int the same day
            {
                string searchPath = beginDir + "\\" +
                                    startDir.CameraID + "\\" +
                                    startDir.Year + "\\" +
                                    startDir.Month + "\\" +
                                    startDir.Day + "\\" + subSearchPath + "\\";
                if (Directory.Exists(searchPath))
                {
                    string[] dirFile = Directory.GetDirectories(searchPath);
                    foreach (string strFile in dirFile)
                    {
                        if (Directory.Exists(strFile))
                        {
                            string[] files = Directory.GetFiles(strFile);
                            foreach (string file in files)
                            {
                                DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                if (IsValidImageFile(fileName))
                                {
                                    int hour = int.Parse(fileName.Substring(9, 2));
                                    int minute = int.Parse(fileName.Substring(11, 2));
                                    int second = int.Parse(fileName.Substring(13, 2));

                                    if (hour >= 0 && hour <= 23 &&
                                        minute >= 0 && minute <= 59 &&
                                        second >= 0 && second <= 59)
                                    {

                                        DateTime dateTime = new DateTime(startYear, startMonth, startDay, hour, minute, second);
                                        if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                        {
                                            fileList.Add(file);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (startYear == endYear &&
                     startMonth == endMonth &&
                     startDay < endDay)//accross the day
            {
                for (int i = startDay; i <= endDay; i++)
                {
                    string searchPath = beginDir + "\\" +
                                        startDir.CameraID + "\\" +
                                        startDir.Year + "\\" +
                                        startDir.Month + "\\" +
                                        i.ToString("D2") + "\\" + subSearchPath + "\\";

                    if (Directory.Exists(searchPath))
                    {
                        string[] dirFile = Directory.GetDirectories(searchPath);

                        foreach (string strFile in dirFile)
                        {
                           if (Directory.Exists(strFile))
                        {
                            string[] files = Directory.GetFiles(strFile);
                            foreach (string file in files)
                            {

                                    DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                    DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                    string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                    if (IsValidImageFile(fileName))
                                    {
                                        int hour = int.Parse(fileName.Substring(9, 2));
                                        int minute = int.Parse(fileName.Substring(11, 2));
                                        int second = int.Parse(fileName.Substring(13, 2));

                                        if (hour >= 0 && hour <= 23 &&
                                           minute >= 0 && minute <= 59 &&
                                           second >= 0 && second <= 59)
                                        {
                                            DateTime dateTime = new DateTime(startYear, startMonth, i, hour, minute, second);
                                            if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                            {
                                                fileList.Add(file);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (startYear == endYear &&
                     startMonth < endMonth)//accross the month
            {
                for (int i = startMonth; i <= endMonth; i++)
                {
                    int tmpDay1, tmpDay2;
                    if (i == startMonth)
                        tmpDay1 = startDay;
                    else
                        tmpDay1 = 1;
                    if (i == endMonth)
                        tmpDay2 = endDay;
                    else
                        tmpDay2 = 31;

                    for (int j = tmpDay1; j <= tmpDay2; j++)
                    {
                        string searchPath = beginDir + "\\" +
                                            startDir.CameraID + "\\" +
                                            startDir.Year + "\\" +
                                            i.ToString("D2") + "\\" +
                                            j.ToString("D2") + "\\" + subSearchPath + "\\";
                        if (Directory.Exists(searchPath))
                        {
                            string[] dirFile = Directory.GetDirectories(searchPath);
                            foreach (string strFile in dirFile)
                            {
                                string[] files = Directory.GetFiles(strFile);
                                foreach (string file in files)
                                {
                                    DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                    DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                    string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                    if (IsValidImageFile(fileName))
                                    {
                                        int hour = int.Parse(fileName.Substring(9, 2));
                                        int minute = int.Parse(fileName.Substring(11, 2));
                                        int second = int.Parse(fileName.Substring(13, 2));

                                        if (hour >= 0 && hour <= 23 &&
                                            minute >= 0 && minute <= 59 &&
                                            second >= 0 && second <= 59)
                                        {

                                            DateTime dateTime = new DateTime(startYear, i, j, hour, minute, second);
                                            if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                            {
                                                fileList.Add(file);
                                            }

                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (startYear < endYear)//accross year
            {
                for (int i = startYear; i <= endYear; i++)
                {
                    int tmpMonth1, tmpMonth2;
                    if (i == startYear)
                        tmpMonth1 = startMonth;
                    else
                        tmpMonth1 = 1;
                    if (i == endYear)
                        tmpMonth2 = endMonth;
                    else
                        tmpMonth2 = 12;

                    for (int j = tmpMonth1; j <= tmpMonth2; j++)
                    {
                        int tmpDay1, tmpDay2;
                        if (i == startYear)
                            tmpDay1 = startDay;
                        else
                            tmpDay1 = 1;
                        if (i == endYear)
                            tmpDay2 = endDay;
                        else
                            tmpDay2 = 31;

                        for (int k = tmpDay1; k <= tmpDay2; k++)
                        {
                            string searchPath = beginDir + "\\" +
                                                startDir.CameraID + "\\" +
                                                i.ToString() + "\\" +
                                                j.ToString("D2") + "\\" +
                                                k.ToString("D2") + "\\" + subSearchPath + "\\";
                            if (Directory.Exists(searchPath))
                            {
                                string[] dirFile = Directory.GetDirectories(searchPath);
                                foreach (string strFile in dirFile)
                                {
                                    string[] files = Directory.GetFiles(strFile);

                                    foreach (string file in files)
                                    {
                                        DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                        DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                        string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                        if (IsValidImageFile(fileName))
                                        {
                                            int hour = int.Parse(fileName.Substring(9, 2));
                                            int minute = int.Parse(fileName.Substring(11, 2));
                                            int second = int.Parse(fileName.Substring(13, 2));

                                            if (hour >= 0 && hour <= 23 &&
                                                minute >= 0 && minute <= 59 &&
                                                second >= 0 && second <= 59)
                                            {

                                                DateTime dateTime = new DateTime(i, j, k, hour, minute, second);
                                                if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                                {
                                                    fileList.Add(file);
                                                }

                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (fileList.Count > 0)
            {
                string[] files = new string[fileList.Count];
                int i = 0;
                foreach (string str in fileList)
                {
                    files[i++] = str;
                }
                return files;
            }

            return new string[0];
        }
コード例 #5
0
        private void queryBtn_Click(object sender, EventArgs e)
        {
            this.bestPicListView.Clear();
            this.imageList1.Images.Clear();
            this.secPicListView.Clear();
            this.imageList2.Images.Clear();
            this.pictureBox1.Image = null;

            if (this.comboBox1.Text == "" || this.comboBox1.Text == null)
            {
                MessageBox.Show("请选择要查询的摄像头ID", "警告");
                return;
            }
            string cameraID = int.Parse(this.comboBox1.Text).ToString("D2");

            //judge the input validation
            DateTime date1 = this.dateTimePicker1.Value;
            DateTime date2 = this.dateTimePicker2.Value;
            DateTime time1 = this.timeEdit1.Time;
            DateTime time2 = this.timeEdit2.Time;

            DateTime dateTime1 = new DateTime(date1.Year, date1.Month, date1.Day, time1.Hour, time1.Minute, time1.Second);
            DateTime dateTime2 = new DateTime(date2.Year, date2.Month, date2.Day, time2.Hour, time2.Minute, time2.Second);
            if (dateTime1 >= dateTime2)
            {
                MessageBox.Show("时间起点不应该大于或者等于时间终点,请重新输入!", "警告");
                return;
            }
            /////
            string year1 = dateTime1.Year.ToString("D4");
            string month1 = dateTime1.Month.ToString("D2");
            string day1 = dateTime1.Day.ToString("D2");
            string hour1 = dateTime1.Hour.ToString("D2");
            string minute1 = dateTime1.Minute.ToString("D2");
            string second1 = dateTime1.Second.ToString("D2");

            string year2 = dateTime2.Year.ToString("D4");
            string month2 = dateTime2.Month.ToString("D2");
            string day2 = dateTime2.Day.ToString("D2");
            string hour2 = dateTime2.Hour.ToString("D2");
            string minute2 = dateTime2.Minute.ToString("D2");
            string second2 = dateTime2.Second.ToString("D2");

            Query.ImageDirSys startDir = new ImageDirSys(cameraID, year1, month1, day1, hour1, minute1, second1);
            Query.ImageDirSys endDir = new ImageDirSys(cameraID, year2, month2, day2, hour2, minute2, second2);
            Query.ImageSearch imageSearch = new ImageSearch();

            string[] files = imageSearch.SearchImages(startDir, endDir, RemoteImaging.Query.ImageDirSys.SearchType.PicType);
            if (files == null)
            {
                MessageBox.Show("没有搜索到满足条件的图片!", "警告");
                return;
            }

            this.bestPicListView.Scrollable = true;
            this.bestPicListView.MultiSelect = false;
            this.bestPicListView.View = View.LargeIcon;
            this.bestPicListView.LargeImageList = imageList1;

            for (int i = 0; i < files.Length; ++i)
            {
                this.imageList1.Images.Add(Image.FromFile(files[i]));
                string text = System.IO.Path.GetFileName(files[i]);
                ListViewItem item = new ListViewItem()
                {
                    Tag = files[i],
                    Text = text,
                    ImageIndex = i
                };
                this.bestPicListView.Items.Add(item);
            }
        }
コード例 #6
0
        public static string[] SearchImages(ImageDirSys startDir, ImageDirSys endDir, ImageDirSys.SearchType searchType)
        {
            int startYear   = int.Parse(startDir.Year);
            int startMonth  = int.Parse(startDir.Month);
            int startDay    = int.Parse(startDir.Day);
            int startHour   = int.Parse(startDir.Hour);
            int startMinute = int.Parse(startDir.Minute);
            int startSecond = int.Parse(startDir.Second);
            int endYear     = int.Parse(endDir.Year);
            int endMonth    = int.Parse(endDir.Month);
            int endDay      = int.Parse(endDir.Day);
            int endHour     = int.Parse(endDir.Hour);
            int endMinute   = int.Parse(endDir.Minute);
            int endSecond   = int.Parse(endDir.Second);

            string beginDir      = ImageDirSys.BeginDir;
            string subSearchPath = "";

            if (searchType == ImageDirSys.SearchType.PicType)
            {
                subSearchPath = Query.ImageDirSys.IconPath;
            }
            else if (searchType == ImageDirSys.SearchType.VideoType)
            {
                subSearchPath = Query.ImageDirSys.VideoPath;
            }

            ArrayList fileList = new ArrayList();


            if (startYear == endYear &&
                startMonth == endMonth &&
                startDay == endDay)//int the same day
            {
                string searchPath = beginDir + "\\" +
                                    startDir.CameraID + "\\" +
                                    startDir.Year + "\\" +
                                    startDir.Month + "\\" +
                                    startDir.Day + "\\" + subSearchPath + "\\";
                if (Directory.Exists(searchPath))
                {
                    string[] dirFile = Directory.GetDirectories(searchPath);
                    foreach (string strFile in dirFile)
                    {
                        if (Directory.Exists(strFile))
                        {
                            string[] files = Directory.GetFiles(strFile);
                            foreach (string file in files)
                            {
                                DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                if (IsValidImageFile(fileName))
                                {
                                    int hour   = int.Parse(fileName.Substring(9, 2));
                                    int minute = int.Parse(fileName.Substring(11, 2));
                                    int second = int.Parse(fileName.Substring(13, 2));

                                    if (hour >= 0 && hour <= 23 &&
                                        minute >= 0 && minute <= 59 &&
                                        second >= 0 && second <= 59)
                                    {
                                        DateTime dateTime = new DateTime(startYear, startMonth, startDay, hour, minute, second);
                                        if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                        {
                                            fileList.Add(file);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (startYear == endYear &&
                     startMonth == endMonth &&
                     startDay < endDay)//accross the day
            {
                for (int i = startDay; i <= endDay; i++)
                {
                    string searchPath = beginDir + "\\" +
                                        startDir.CameraID + "\\" +
                                        startDir.Year + "\\" +
                                        startDir.Month + "\\" +
                                        i.ToString("D2") + "\\" + subSearchPath + "\\";

                    if (Directory.Exists(searchPath))
                    {
                        string[] dirFile = Directory.GetDirectories(searchPath);

                        foreach (string strFile in dirFile)
                        {
                            if (Directory.Exists(strFile))
                            {
                                string[] files = Directory.GetFiles(strFile);
                                foreach (string file in files)
                                {
                                    DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                    DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                    string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                    if (IsValidImageFile(fileName))
                                    {
                                        int hour   = int.Parse(fileName.Substring(9, 2));
                                        int minute = int.Parse(fileName.Substring(11, 2));
                                        int second = int.Parse(fileName.Substring(13, 2));

                                        if (hour >= 0 && hour <= 23 &&
                                            minute >= 0 && minute <= 59 &&
                                            second >= 0 && second <= 59)
                                        {
                                            DateTime dateTime = new DateTime(startYear, startMonth, i, hour, minute, second);
                                            if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                            {
                                                fileList.Add(file);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (startYear == endYear &&
                     startMonth < endMonth)//accross the month
            {
                for (int i = startMonth; i <= endMonth; i++)
                {
                    int tmpDay1, tmpDay2;
                    if (i == startMonth)
                    {
                        tmpDay1 = startDay;
                    }
                    else
                    {
                        tmpDay1 = 1;
                    }
                    if (i == endMonth)
                    {
                        tmpDay2 = endDay;
                    }
                    else
                    {
                        tmpDay2 = 31;
                    }

                    for (int j = tmpDay1; j <= tmpDay2; j++)
                    {
                        string searchPath = beginDir + "\\" +
                                            startDir.CameraID + "\\" +
                                            startDir.Year + "\\" +
                                            i.ToString("D2") + "\\" +
                                            j.ToString("D2") + "\\" + subSearchPath + "\\";
                        if (Directory.Exists(searchPath))
                        {
                            string[] dirFile = Directory.GetDirectories(searchPath);
                            foreach (string strFile in dirFile)
                            {
                                string[] files = Directory.GetFiles(strFile);
                                foreach (string file in files)
                                {
                                    DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                    DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                    string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                    if (IsValidImageFile(fileName))
                                    {
                                        int hour   = int.Parse(fileName.Substring(9, 2));
                                        int minute = int.Parse(fileName.Substring(11, 2));
                                        int second = int.Parse(fileName.Substring(13, 2));

                                        if (hour >= 0 && hour <= 23 &&
                                            minute >= 0 && minute <= 59 &&
                                            second >= 0 && second <= 59)
                                        {
                                            DateTime dateTime = new DateTime(startYear, i, j, hour, minute, second);
                                            if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                            {
                                                fileList.Add(file);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (startYear < endYear)//accross year
            {
                for (int i = startYear; i <= endYear; i++)
                {
                    int tmpMonth1, tmpMonth2;
                    if (i == startYear)
                    {
                        tmpMonth1 = startMonth;
                    }
                    else
                    {
                        tmpMonth1 = 1;
                    }
                    if (i == endYear)
                    {
                        tmpMonth2 = endMonth;
                    }
                    else
                    {
                        tmpMonth2 = 12;
                    }


                    for (int j = tmpMonth1; j <= tmpMonth2; j++)
                    {
                        int tmpDay1, tmpDay2;
                        if (i == startYear)
                        {
                            tmpDay1 = startDay;
                        }
                        else
                        {
                            tmpDay1 = 1;
                        }
                        if (i == endYear)
                        {
                            tmpDay2 = endDay;
                        }
                        else
                        {
                            tmpDay2 = 31;
                        }

                        for (int k = tmpDay1; k <= tmpDay2; k++)
                        {
                            string searchPath = beginDir + "\\" +
                                                startDir.CameraID + "\\" +
                                                i.ToString() + "\\" +
                                                j.ToString("D2") + "\\" +
                                                k.ToString("D2") + "\\" + subSearchPath + "\\";
                            if (Directory.Exists(searchPath))
                            {
                                string[] dirFile = Directory.GetDirectories(searchPath);
                                foreach (string strFile in dirFile)
                                {
                                    string[] files = Directory.GetFiles(strFile);

                                    foreach (string file in files)
                                    {
                                        DateTime dateTime1 = new DateTime(startYear, startMonth, startDay, startHour, startMinute, startSecond);
                                        DateTime dateIime2 = new DateTime(endYear, endMonth, endDay, endHour, endMinute, endSecond);

                                        string fileName = System.IO.Path.GetFileNameWithoutExtension(file);
                                        if (IsValidImageFile(fileName))
                                        {
                                            int hour   = int.Parse(fileName.Substring(9, 2));
                                            int minute = int.Parse(fileName.Substring(11, 2));
                                            int second = int.Parse(fileName.Substring(13, 2));

                                            if (hour >= 0 && hour <= 23 &&
                                                minute >= 0 && minute <= 59 &&
                                                second >= 0 && second <= 59)
                                            {
                                                DateTime dateTime = new DateTime(i, j, k, hour, minute, second);
                                                if ((dateTime1 <= dateTime) && (dateTime <= dateIime2))
                                                {
                                                    fileList.Add(file);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }


            if (fileList.Count > 0)
            {
                string[] files = new string[fileList.Count];
                int      i     = 0;
                foreach (string str in fileList)
                {
                    files[i++] = str;
                }
                return(files);
            }

            return(new string[0]);
        }
コード例 #7
0
        private void queryBtn_Click(object sender, EventArgs e)
        {
            string cameraID = this.comboBox1.Text;

            string dataStr1    = this.dateTimePicker1.Text;
            int    indexYear1  = dataStr1.IndexOf("年");
            int    indexMonth1 = dataStr1.IndexOf("月");
            int    indexDay1   = dataStr1.IndexOf("日");

            string year1  = dataStr1.Substring(0, 4);
            string month1 = int.Parse(dataStr1.Substring(indexYear1 + 1, indexMonth1 - indexYear1 - 1)).ToString("D2");
            string day1   = int.Parse(dataStr1.Substring(indexMonth1 + 1, indexDay1 - indexMonth1 - 1)).ToString("D2");

            string timeStr1 = this.timeEdit1.Text;
            int    index1   = timeStr1.IndexOf(":");
            int    index2   = timeStr1.LastIndexOf(":");

            string hour1   = timeStr1.Substring(0, index1);
            string minute1 = timeStr1.Substring(index1 + 1, index2 - index1 - 1);
            string second1 = timeStr1.Substring(index2 + 1, timeStr1.Length - index2 - 1);

            string dataStr2    = this.dateTimePicker2.Text;
            int    indexYear2  = dataStr2.IndexOf("年");
            int    indexMonth2 = dataStr2.IndexOf("月");
            int    indexDay2   = dataStr2.IndexOf("日");

            string year2  = dataStr2.Substring(0, 4);
            string month2 = int.Parse(dataStr2.Substring(indexYear2 + 1, indexMonth2 - indexYear2 - 1)).ToString("D2");
            string day2   = int.Parse(dataStr2.Substring(indexMonth2 + 1, indexDay2 - indexMonth2 - 1)).ToString("D2");

            string timeStr2 = this.timeEdit2.Text;
            int    index3   = timeStr2.IndexOf(":");
            int    index4   = timeStr2.LastIndexOf(":");

            string hour2   = timeStr2.Substring(0, index3);
            string minute2 = timeStr2.Substring(index3 + 1, index4 - index3 - 1);
            string second2 = timeStr2.Substring(index4 + 1, timeStr2.Length - index4 - 1);

            //judge the input validation
            DateTime dateTime1 = new DateTime(int.Parse(year1), int.Parse(month1), int.Parse(day1), int.Parse(hour1), int.Parse(minute1), int.Parse(second1));
            DateTime dateTime2 = new DateTime(int.Parse(year2), int.Parse(month2), int.Parse(day2), int.Parse(hour2), int.Parse(minute2), int.Parse(second2));

            if (dateTime1 >= dateTime2)
            {
                MessageBox.Show("时间起点不应该大于或者等于时间终点,请重新输入!", "警告");
                return;
            }
            //

            this.bestPicListView.Clear();
            this.imageList1.Images.Clear();

            Query.ImageDirSys startDir    = new ImageDirSys(cameraID, year1, month1, day1, hour1, minute1, second1);
            Query.ImageDirSys endDir      = new ImageDirSys(cameraID, year2, month2, day2, hour2, minute2, second2);
            Query.ImageSearch imageSearch = new ImageSearch();

            string[] files = imageSearch.SearchImages(startDir, endDir, RemoteImaging.Query.ImageDirSys.BeginDir);
            if (files == null)
            {
                MessageBox.Show("没有搜索到满足条件的图片!", "警告");
                return;
            }

            this.bestPicListView.Scrollable     = true;
            this.bestPicListView.MultiSelect    = false;
            this.bestPicListView.View           = View.LargeIcon;
            this.bestPicListView.LargeImageList = imageList1;

            for (int i = 0; i < files.Length; i++)
            {
                this.imageList1.Images.Add(Image.FromFile(files[i]));
                this.bestPicListView.Items.Add(System.IO.Path.GetFileName(files[i]), i);
            }
        }
コード例 #8
0
        private void queryBtn_Click(object sender, EventArgs e)
        {
            this.bestPicListView.Clear();
            this.imageList1.Images.Clear();
            this.secPicListView.Clear();
            this.imageList2.Images.Clear();
            this.pictureBox1.Image = null;

            if (this.comboBox1.Text == "" || this.comboBox1.Text == null)
            {
                MessageBox.Show("请选择要查询的摄像头ID", "警告");
                return;
            }
            string cameraID = int.Parse(this.comboBox1.Text).ToString("D2");


            //judge the input validation
            DateTime date1 = this.dateTimePicker1.Value;
            DateTime date2 = this.dateTimePicker2.Value;
            DateTime time1 = this.timeEdit1.Time;
            DateTime time2 = this.timeEdit2.Time;

            DateTime dateTime1 = new DateTime(date1.Year, date1.Month, date1.Day, time1.Hour, time1.Minute, time1.Second);
            DateTime dateTime2 = new DateTime(date2.Year, date2.Month, date2.Day, time2.Hour, time2.Minute, time2.Second);

            if (dateTime1 >= dateTime2)
            {
                MessageBox.Show("时间起点不应该大于或者等于时间终点,请重新输入!", "警告");
                return;
            }
            /////
            string year1   = dateTime1.Year.ToString("D4");
            string month1  = dateTime1.Month.ToString("D2");
            string day1    = dateTime1.Day.ToString("D2");
            string hour1   = dateTime1.Hour.ToString("D2");
            string minute1 = dateTime1.Minute.ToString("D2");
            string second1 = dateTime1.Second.ToString("D2");

            string year2   = dateTime2.Year.ToString("D4");
            string month2  = dateTime2.Month.ToString("D2");
            string day2    = dateTime2.Day.ToString("D2");
            string hour2   = dateTime2.Hour.ToString("D2");
            string minute2 = dateTime2.Minute.ToString("D2");
            string second2 = dateTime2.Second.ToString("D2");

            Query.ImageDirSys startDir    = new ImageDirSys(cameraID, year1, month1, day1, hour1, minute1, second1);
            Query.ImageDirSys endDir      = new ImageDirSys(cameraID, year2, month2, day2, hour2, minute2, second2);
            Query.ImageSearch imageSearch = new ImageSearch();

            string[] files = imageSearch.SearchImages(startDir, endDir, RemoteImaging.Query.ImageDirSys.SearchType.PicType);
            if (files == null)
            {
                MessageBox.Show("没有搜索到满足条件的图片!", "警告");
                return;
            }

            this.bestPicListView.Scrollable     = true;
            this.bestPicListView.MultiSelect    = false;
            this.bestPicListView.View           = View.LargeIcon;
            this.bestPicListView.LargeImageList = imageList1;

            for (int i = 0; i < files.Length; ++i)
            {
                this.imageList1.Images.Add(Image.FromFile(files[i]));
                string       text = System.IO.Path.GetFileName(files[i]);
                ListViewItem item = new ListViewItem()
                {
                    Tag        = files[i],
                    Text       = text,
                    ImageIndex = i
                };
                this.bestPicListView.Items.Add(item);
            }
        }
コード例 #9
0
ファイル: QueryForm.cs プロジェクト: dalinhuang/appcollection
        private void queryBtn_Click(object sender, EventArgs e)
        {
            string cameraID = this.comboBox1.Text;

            string dataStr1 = this.dateTimePicker1.Text;
            int indexYear1 = dataStr1.IndexOf("年");
            int indexMonth1 = dataStr1.IndexOf("月");
            int indexDay1 = dataStr1.IndexOf("日");

            string year1 = dataStr1.Substring(0,4);
            string month1 = int.Parse(dataStr1.Substring(indexYear1+1, indexMonth1-indexYear1-1)).ToString("D2");
            string day1 = int.Parse(dataStr1.Substring(indexMonth1+1,indexDay1-indexMonth1-1)).ToString("D2");

            string timeStr1 = this.timeEdit1.Text;
            int index1 = timeStr1.IndexOf(":");
            int index2 = timeStr1.LastIndexOf(":");

            string hour1 = timeStr1.Substring(0,index1);
            string minute1 = timeStr1.Substring(index1+1,index2-index1-1);
            string second1 = timeStr1.Substring(index2+1,timeStr1.Length-index2-1);

            string dataStr2 = this.dateTimePicker2.Text;
            int indexYear2 = dataStr2.IndexOf("年");
            int indexMonth2 = dataStr2.IndexOf("月");
            int indexDay2 = dataStr2.IndexOf("日");

            string year2 = dataStr2.Substring(0, 4);
            string month2 = int.Parse(dataStr2.Substring(indexYear2 + 1, indexMonth2 - indexYear2 - 1)).ToString("D2");
            string day2 = int.Parse(dataStr2.Substring(indexMonth2 + 1, indexDay2 - indexMonth2 - 1)).ToString("D2");

            string timeStr2 = this.timeEdit2.Text;
            int index3 = timeStr2.IndexOf(":");
            int index4 = timeStr2.LastIndexOf(":");

            string hour2 = timeStr2.Substring(0, index3);
            string minute2 = timeStr2.Substring(index3 + 1, index4 - index3 - 1);
            string second2 = timeStr2.Substring(index4 + 1, timeStr2.Length - index4 - 1);

            //judge the input validation
            DateTime dateTime1 = new DateTime(int.Parse(year1),int.Parse(month1),int.Parse(day1),int.Parse(hour1),int.Parse(minute1),int.Parse(second1));
            DateTime dateTime2 = new DateTime(int.Parse(year2), int.Parse(month2), int.Parse(day2), int.Parse(hour2), int.Parse(minute2), int.Parse(second2));
            if (dateTime1 >= dateTime2)
            {
                MessageBox.Show("时间起点不应该大于或者等于时间终点,请重新输入!","警告");
                return;
            }
            //

            this.bestPicListView.Clear();
            this.imageList1.Images.Clear();

            Query.ImageDirSys startDir = new ImageDirSys(cameraID, year1, month1, day1, hour1, minute1, second1);
            Query.ImageDirSys endDir = new ImageDirSys(cameraID, year2, month2, day2, hour2, minute2, second2);
            Query.ImageSearch imageSearch = new ImageSearch();

            string[] files = imageSearch.SearchImages(startDir, endDir, RemoteImaging.Query.ImageDirSys.BeginDir);
            if (files == null)
            {
                MessageBox.Show("没有搜索到满足条件的图片!","警告");
                return;
            }

            this.bestPicListView.Scrollable = true;
            this.bestPicListView.MultiSelect = false;
            this.bestPicListView.View = View.LargeIcon;
            this.bestPicListView.LargeImageList = imageList1;

            for (int i = 0; i < files.Length; i++)
            {
                this.imageList1.Images.Add(Image.FromFile(files[i]));
                this.bestPicListView.Items.Add(System.IO.Path.GetFileName(files[i]), i);
            }
        }