[問題] 雙CCD攝影機,顯示不同畫面

看板C_Sharp作者 (達達)時間8年前 (2016/07/04 16:15), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
小弟測試如何讓兩支CCD攝影機同時顯示不同畫面 但是程式一次都只能抓到其中一台攝影機的畫面,程式畫面都是顯示同一台 已經有使用PYLON VIEWER測試過兩台CCD攝影機的功能都是正常的 都有傳送封包.想問問各位大大幫忙看一下小弟的程式哪裡出錯了 private void CaptureCamera()//啟動相機的執行續 { _cameraThread = new Thread(new ThreadStart(CaptureCameraCallback)); _cameraThread.Start(); } private void CaptureCameraCallback() { CvCapture cap0 = CvCapture.FromCamera(0);//PO0 IplImage tpr = Cv.LoadImage("CaptureR.bmp", LoadMode.Color);//讀樣 版圖檔案 CvCapture cap1 = CvCapture.FromCamera(1);//PO1 IplImage tpl = Cv.LoadImage("CaptureL.bmp", LoadMode.Color);//讀樣 版圖檔案 CvPoint minloc, maxloc; double minval, maxval; myUI("", minloc_X);//minloc_X寫為空白 while (true) { IplImage img0 = cap0.QueryFrame(); IplImage res0 = Cv.CreateImage(Cv.Size(img0.Width - tpr.Width + 1, img0.Height - tpr.Height + 1), BitDepth.F32, 1);//MatchTemplate result的 公式 Cv.MatchTemplate(img0, tpr, res0, MatchTemplateMethod.SqDiffNormed);//MatchTemplate(image, templ, result, method) 影像對比 Cv.MinMaxLoc(res0, out minval, out maxval, out minloc, out maxloc, null); //Cv.Rectangle(img, Cv.Point(minloc.X , minloc.Y), Cv.Point(minloc.X + tpl.Width, minloc.Y + tpl.Height), CvColor.Red, 1, 0, 0); Bitmap bm0 = BitmapConverter.ToBitmap(img0);//將img轉成BMP檔 bm0.SetResolution(pictureBox2.Width, pictureBox2.Height);//設 定BMP檔的分辨率為picturebox2的長寬 pictureBox2.Image = bm0; IplImage img1 = cap1.QueryFrame(); IplImage res1 = Cv.CreateImage(Cv.Size(img1.Width - tpl.Width + 1, img1.Height - tpl.Height + 1), BitDepth.F32, 1);//MatchTemplate result的 公式 Cv.MatchTemplate(img1, tpl, res1, MatchTemplateMethod.SqDiffNormed);//MatchTemplate(image, templ, result, method) 影像對比 Cv.MinMaxLoc(res1, out minval, out maxval, out minloc, out maxloc, null); //Cv.Rectangle(img, Cv.Point(minloc.X , minloc.Y), Cv.Point(minloc.X + tpl.Width, minloc.Y + tpl.Height), CvColor.Red, 1, 0, 0); Bitmap bm1 = BitmapConverter.ToBitmap(img1);//將img轉成BMP檔 bm1.SetResolution(pictureBox1.Width, pictureBox1.Height);//設 定BMP檔的分辨率為picturebox1的長寬 pictureBox1.Image = bm1; } -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.125.20.117 ※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1467620113.A.688.html
文章代碼(AID): #1NUXiHQ8 (C_Sharp)
文章代碼(AID): #1NUXiHQ8 (C_Sharp)