You are on page 1of 2

Hin th nhiu khung hnh (multi-view) vi OpenCV

Nh gii thiu cc bi vit trc y, OpenCV l mt th vin m ngun m h tr cho vic trin khai v nghin cu cc ng dng computer vision. Th vin ny cng cung cp nhng chc nng rt mnh trong vic c, hin th cc nh dng nh v video. Mt cp hm rt quen thuc dng to ra mt ca s view mi v hin th nh l cvNamedWindow, cvShowImage. Tuy nhin yu im ca Open CV l ch h tr chc nng hin th ch yu ngi dng kim chng kt qu, v n to ra nhng ca s ring bit ngai giao din iu khin chnh, trng rt ri rc. Hn th na trong trng hp bn cn hin th nhiu kt qu khc nhau, nhiu video v nhiu hnh nh cng lc th la mn hnh ca bn s tm lum cc ca s. Vy gii php no gip bn c th va tn dng sc mnh c sn ca OpenCV va c th thit k mt giao din hp nhn. C ba cch: Mt l bn s dng mt lp m rng ca OpenCV do Adrian Kaehler c tn l Multiwin nhm gom nhiu ca s hin th ca OpenCV thnh mt di dng ma trn. Hai l bn hy thc hin thao tc gp nhiu nh nh thnh mt nh ln, gom frame ca nhiu movie thnh mt frame ln ri mi show ra ca s view ca OpenCV. Ba l phng php m tui my m ra xut pht t kin thc lp trnh C trn window nh sau: cc i tng trn mn hnh ca bn u l nhng ca s, cc ca s u c Id v c th c ca s cha cha n hoc ca s con. Nu coi mi mn hnh view to bi hai hm trn l mt ca s th bn han tan c th kt chng vo nhng ca s khc c v tr c nh trn mn hnh chnh ca ng dng nh l nhng ca s con. Khi bn s c kt qu ging nh vic gn nhiu mn hnh tivi ln nhiu ci inh trn mt bc tng :p. Sau y l mt an code lm chuyn , nh nh con th nhng cng mt ca tui my ting, b con nh ghi cng khi s dng :) cvNamedWindow("Ten cua so OpenCV", 1); HWND hWnd = (HWND) cvGetWindowHandle("Ten cua so OpenCV"); HWND hParent = ::GetParent(hWnd); ::SetParent(hWnd, GetDlgItem(IDC_STATIC_OUTPUT1)->m_hWnd); ::ShowWindow(hParent, SW_HIDE); V sau ch cn update ca s view bng hm cvShowImage vi ni dung v ti thi im mong mun th t ng n s hin th gn gng trong phm vi control cha thit lp. V y l ng dng visual surveillance u tin ca ti c p dng k thut ny.

Lu : trong v d ny ti s dng group box control lm control cha vi ID l IDC_STATIC_OUTPUT1, v lp trnh bng VS2008 nn ch n gin ko th control vo form, nh v tr ri t tn ID nh mong mun trong thuc tnh l xong. Nn t tn ca ca s OpenCV sao cho kh trng lp, v d Ten cua so OpenCV -> VnSLib_Shadow Cc bn mun s dng phng php 1 c th download source code ca Adrian Kaehler y. Trong trng hp bn mun s dng phng php Made in Vietnam ca Bioz th vui lng ti b v d OPENCV ti kho sn phm ca IEEV Binh Nguyen - Bioz