Пример #1
0
        public bool ReadINIFile()
        {
            //속성파일 생성
            string inifile = Application.StartupPath + "\\setting.int";

            if (!File.Exists(inifile))
                return false;

            try
            {
                StreamReader reader = new StreamReader(inifile);

                string tstr = reader.ReadLine();
                m_ClientsNum = int.Parse(tstr);

                m_NetworkType = reader.ReadLine();

                //아이피 읽어들이기
                m_Avips = new string[m_ClientsNum];

                for (int i = 0; i < m_ClientsNum; i++)
                {
                    m_Avips[i] = reader.ReadLine();
                }

                //패스워드 읽기
                m_PassWord = reader.ReadLine();

                //카메라 파라미터 읽기

                m_AvParam = new AVParam[m_ClientsNum];

                for (int i = 0; i < m_ClientsNum; i++)
                {
                    m_AvParam[i] = new AVParam();
                    tstr = reader.ReadLine();
                    m_AvParam[i].left = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].top = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].width = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].height = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].fps = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].res = (IMAGE_RESOLUTION)Enum.Parse(typeof(IMAGE_RESOLUTION), tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].codecType = (AVCodecType)Enum.Parse(typeof(AVCodecType), tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].quality = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].intraFramePeriod = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].bitrate = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].stream_id = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].dn_mode = (DN_modes)Enum.Parse(typeof(DN_modes), tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].light = (Light_modes)Enum.Parse(typeof(Light_modes), tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].CameraMode = int.Parse(tstr);
                    tstr = reader.ReadLine();
                    m_AvParam[i].ShutterSpeed = int.Parse(tstr);


                }

                tstr = reader.ReadLine();
                m_TargetType = (TargetType)Enum.Parse(typeof(TargetType), tstr);
                tstr = reader.ReadLine();
                m_TargetWidth = double.Parse(tstr);
                tstr = reader.ReadLine();
                m_TargetHeight = double.Parse(tstr);
                tstr = reader.ReadLine();
                m_TargetLimit = double.Parse(tstr);
                tstr = reader.ReadLine();
                m_RotateLimit = double.Parse(tstr);
                tstr = reader.ReadLine();
                m_ScaleLimit = double.Parse(tstr);
                m_DataFolder = reader.ReadLine();

                //타깃정보 입력
                tstr = reader.ReadLine();
                if (tstr.Length > 0)
                {
                    int imgnum = int.Parse(tstr);
                    m_Images = new ImageDb[imgnum];

                    for (int i = 0; i < imgnum; i++)
                    {
                        m_Images[i] = new ImageDb();
                        tstr = reader.ReadLine();
                        tstr = reader.ReadLine();
                        if (tstr == "initialized")
                        {
                            m_Images[i].m_Initialized = true;
                            tstr = reader.ReadLine();
                            int tnum = int.Parse(tstr);

                            if (tnum > 0)
                            {
                                m_Images[i].m_Targets = new TargetDb[tnum];

                                for (int j = 0; j < tnum; j++)
                                {
                                    m_Images[i].m_Targets[j] = new TargetDb();
                                    m_Images[i].m_Targets[j].m_ID = reader.ReadLine();
                                    tstr = reader.ReadLine();
                                    m_Images[i].m_Targets[j].ix = double.Parse(tstr);
                                    tstr = reader.ReadLine();
                                    m_Images[i].m_Targets[j].iy = double.Parse(tstr);
                                    tstr = reader.ReadLine();
                                    m_Images[i].m_Targets[j].m_DWidth = double.Parse(tstr);
                                    tstr = reader.ReadLine();
                                    m_Images[i].m_Targets[j].m_DHeight = double.Parse(tstr);
                                    tstr = reader.ReadLine();

                                    int cnum = int.Parse(tstr);

                                    if (cnum > 0)
                                    {
                                        m_Images[i].m_Targets[j].m_Corners = new PointF[cnum];

                                        for (int x = 0; x < cnum; x++)
                                        {
                                            m_Images[i].m_Targets[j].m_Corners[x] = new PointF();
                                            tstr = reader.ReadLine();
                                            char[] splt = { ',' };
                                            string[] rst = tstr.Split(splt);
                                            m_Images[i].m_Targets[j].m_Corners[x].X = float.Parse(rst[0]);
                                            m_Images[i].m_Targets[j].m_Corners[x].Y = float.Parse(rst[1]);

                                        }
                                    }

                                }
                            }

                            //ResetTargets(false, m_Images[i].m_Targets.Length);

                        }
                        else
                        {
                            m_Images[i].m_Initialized = false;
                        }

                    }
                }

                if (m_ClientsNum >= 1)
                    ResetLayoutPanel(m_ClientsNum);

                //SMS 정보 읽기
                //m_SMS.ID = reader.ReadLine();
                //m_SMS.PW = reader.ReadLine();
                //m_SMS.fromNumber = reader.ReadLine();
                //tstr = reader.ReadLine();
                //int smsnum = int.Parse(tstr);

                //for (int i = 0; i < smsnum; i++)
                //{
                //    tstr = reader.ReadLine();
                //    m_SMS.AddNumber(tstr);
                //}

                reader.Close();


            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
                return false;
            }

            return true;
        }
Пример #2
0
        public int FindDBIndex(ref ImageDb idb, ref TargetCoord tg)
        {
            if (idb.m_Targets == null)
                return -1;

            for (int i = 0; i < idb.m_Targets.Length; i++)
            {
                if (idb.m_Targets[i] != null)
                    if (idb.m_Targets[i].m_ID == tg.m_ID)
                        return i;
            }

            return -1;
        }
Пример #3
0
        private void btnInit_Click(object sender, EventArgs e)
        {
            if (m_ClientsNum == 0)
                return;

            m_Img_Do = false;

            try
            {
                if (m_BGWorker != null)
                {
                    m_BGWorker.CancelAsync();
                }

                CloseFolder();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.ToString());
            }

            m_Images[m_SelCamNum] = new ImageDb();


            m_isInit = true;

            preparethread();

            m_BGWorker = new BackgroundWorker();
            m_BGWorker.WorkerSupportsCancellation = true;
            m_BGWorker.WorkerReportsProgress = true;
            m_BGWorker.DoWork += new DoWorkEventHandler(ReceiveImgOne);
            m_BGWorker.ProgressChanged += new ProgressChangedEventHandler(BGMessage);
            m_BGWorker.RunWorkerAsync(m_SelCamNum);
        }
Пример #4
0
        public void InitImageDb(int num, ref TargetCoord[] targets)
        {
            // 자료구조 생성
            try
            {
                num--;

                if (targets == null)
                {
                    m_ThreadCount--;
                    return;
                }

                if (targets.Length == 0)
                {
                    m_ThreadCount--;
                    return;
                }

                //초기값을 입력함
                if (m_ThreadCount == 0)
                {
                    if (targets != null)
                    {

                        int arrsize = targets.Length;

                        if (m_Images == null)
                            m_Images = new ImageDb[m_ClientsNum];

                        if (m_Images[num] == null)
                            m_Images[num] = new ImageDb();

                        //타겟 넘버링
                        for (int j = 0; j < arrsize; j++)
                        {
                            if (m_Images[num].m_Targets == null)
                            {
                                m_Images[num].m_Targets = new TargetDb[arrsize];
                            }
                            if (m_Images[num].m_Targets[j] == null)
                                m_Images[num].m_Targets[j] = new TargetDb();

                            m_Images[num].m_Targets[j] = new TargetDb();
                            m_Images[num].m_Targets[j].m_ID = targets[j].m_ID.ToString();
                            m_Images[num].m_Targets[j].Arr.Add(targets[j]);
                            m_Images[num].m_Targets[j].ix = targets[j].x;
                            m_Images[num].m_Targets[j].iy = targets[j].y;

                            for (int k = 0; k < 4; k++)
                            {
                                m_Images[num].m_Targets[j].m_Corners[k] = targets[j].Corners[k];
                            }
                        }
                    }
                    else
                    {
                        if (m_ThreadCount != 0)
                            m_ThreadCount = -1;
                    }
                }
                else
                {
                    //타겟 좌표 넣기
                    int arrsize = targets.Length;
                    if (m_Images == null)
                        m_Images = new ImageDb[m_ClientsNum];

                    if (m_Images[num] == null)
                        m_Images[num] = new ImageDb(arrsize);

                    if (m_Images[num].m_Targets == null)
                    {
                        m_Images[num].m_Targets = new TargetDb[arrsize];
                    }


                    //자리 만들기

                    if (m_Images == null)
                        m_Images = new ImageDb[m_ClientsNum];

                    if (m_Images[num] == null)
                        m_Images[num] = new ImageDb(arrsize);

                    for (int j = 0; j < arrsize; j++)
                    {
                        if (m_Images[num].m_Targets == null)
                        {
                            m_Images[num].m_Targets = new TargetDb[arrsize];
                        }

                    }

                    // 초기값 설정하기

                    int diff = arrsize - m_Images[num].m_Targets.Length;


                    for (int x = 0; x < arrsize; x++)
                    {

                        double xx = targets[x].x;
                        double yy = targets[x].y;

                        //int ttnum = FindTarget(ref m_Images[num], xx, yy);
                        int ttnum = FindTarget2(ref m_Images[num], ref targets[x]);

                        if (ttnum == -1)
                        {
                            Array.Resize<TargetDb>(ref m_Images[num].m_Targets, m_Images[num].m_Targets.Length + 1);
                            m_Images[num].m_Targets[m_Images[num].m_Targets.Length - 1] = new TargetDb();
                            m_Images[num].m_Targets[m_Images[num].m_Targets.Length - 1].m_ID = targets[x].m_ID;
                            m_Images[num].m_Targets[m_Images[num].m_Targets.Length - 1].Arr.Add(targets[x]);
                            m_Images[num].m_Targets[m_Images[num].m_Targets.Length - 1].ix = targets[x].x;
                            m_Images[num].m_Targets[m_Images[num].m_Targets.Length - 1].iy = targets[x].y;

                        }
                        else
                        {
                            //값 더하기

                            xx = targets[x].x;
                            yy = targets[x].y;

                            ttnum = FindDBIndex(ref m_Images[num], ref targets[x]);
                            if (ttnum != -1)
                                m_Images[num].m_Targets[ttnum].Arr.Add(targets[x]);

                        }

                    }

                    if (diff < 0)
                        m_ThreadCount--;

                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("후반부" + ee.ToString());
            }
        }