CHƯƠNG 3 THIẾT KẾ VÀ XÂY DỰNG CHƯƠNG TRÌNH
3. Phát hiện đối tƣợng
Private Sub Cuong_Do_Moi_Block(I_In() As Byte, B() As MyBlock) Dim i As Integer, j As Integer
Dim Ki As Integer, Kj As Integer Dim Mi As Integer, Mj As Integer For i = 0 To Block_Height - 1 For j = 0 To Block_Width - 1 For Ki = 0 To 4
For Kj = 0 To 4 Mi = i * 5 + Ki Mj = j * 5 + Kj
B(i, j).GiaTri(Ki, Kj) = I_In(Mi, Mj) Next Kj
Next Ki Next j Next i End Sub
(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu
Public Function Tru_Block(A As MyBlock, B As MyBlock) As Single Dim i As Integer, j As Integer
Dim Ci As Integer, Cj As Integer
Dim tg As Single, T1 As Integer, T2 As Integer Dim AA As MyBlock, BB As MyBlock
Dim TA As Byte, TB As Byte
Dim Tmax As Integer, Tmin As Integer Dim TT As Integer
TA = NhanChap(A.GiaTri(), AA.GiaTri(), H2, 3, 4, 4) TB = NhanChap(B.GiaTri(), BB.GiaTri(), H2, 3, 4, 4) TT = TA
TT = TT - TB Tmax = 0 Tmin = 0 For i = 0 To 4 For j = 0 To 4 If TT > 0 Then
T1 = AA.GiaTri(i, j) T2 = BB.GiaTri(i, j) + TT Else
T1 = AA.GiaTri(i, j) - TT T2 = BB.GiaTri(i, j) End If
If T1 > T2 Then Tmax = Tmax + T1 Tmin = Tmin + T2 Else
Tmax = Tmax + T2 Tmin = Tmin + T1 End If
Next j Next i tg = Tmin
tg = Tmin / Tmax Tru_Block = tg End Function
TIEU LUAN MOI download : skknchat@gmail.com
(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu
Private Function Tru_Anh(MH As Integer, MW As Integer) As Integer Dim i As Integer, j As Integer
Dim Mi As Integer, Mj As Integer Dim Ci As Integer, Cj As Integer
Dim t As Single, tg As Long, Ng As Integer Dim H() As Single, HG() As Byte
Dim HH() As Integer Dim DD As Integer
ReDim H(Block_Height - 1, Block_Width - 1) ReDim HH(Block_Height - 1, Block_Width - 1) ReDim HG(Block_Height - 1, Block_Width - 1) For i = 0 To Block_Height - 1
For j = 0 To Block_Width - 1
H(i, j) = Tru_Block(Block_Goc(i, j), Block_HT(i, j)) t = 1 - H(i, j)
t = t / H(i, j)
HH(i, j) = t * t * 255 Next j
Next i Ng = 1 DD = 1
Do Until DD = 0 Ng = Ng + 1
DD = So_Diem_Den(HH(), Ng) Loop
For i = 0 To Block_Height - 1 For j = 0 To Block_Width - 1 If HH(i, j) > Ng Then tg = tg + 1
ReDim Preserve DS_UV(tg) DS_UV(tg).H = i
DS_UV(tg).W = j End If
Next j Next i
Tru_Anh = tg End Function
(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu
Private Function Tim_Cac_Ung_Vien(MH As Integer, MW As Integer) As Integer
Dim i As Integer, j As Integer Dim k As Integer, H As Integer Dim So_DT As Integer
Dim lc(7) As String Dim Ktra As Boolean
So_DT = Tru_Anh(MH, MW) If So_DT < 10 Then
Tim_Cac_Ung_Vien = 0 Exit Function
End If j = 0
ReDim Preserve DT_UV(j) DT_UV(j).Y1 = DS_UV(0).H DT_UV(j).X1 = DS_UV(0).W DT_UV(j).Y2 = DS_UV(0).H DT_UV(j).X2 = DS_UV(0).W DT_UV(j).TT = True
DT_UV(j).Mo_ta = "|" & DS_UV(0).H & "-" & DS_UV(0).W & "|"
For i = 1 To So_DT
lc(0) = "|" & DS_UV(i).H & "-" & DS_UV(i).W - 1 & "|"
lc(1) = "|" & DS_UV(i).H & "-" & DS_UV(i).W + 1 & "|"
lc(2) = "|" & DS_UV(i).H - 1 & "-" & DS_UV(i).W & "|"
lc(3) = "|" & DS_UV(i).H + 1 & "-" & DS_UV(i).W & "|"
lc(4) = "|" & DS_UV(i).H - 1 & "-" & DS_UV(i).W - 1 & "|"
lc(5) = "|" & DS_UV(i).H - 1 & "-" & DS_UV(i).W + 1 & "|"
lc(6) = "|" & DS_UV(i).H + 1 & "-" & DS_UV(i).W - 1 & "|"
lc(7) = "|" & DS_UV(i).H + 1 & "-" & DS_UV(i).W + 1 & "|"
Ktra = False k = 0
Do Until Ktra Or k = 7 For H = 0 To j
If InStr(DT_UV(H).Mo_ta, lc(k)) > 0 Then Ktra = True
Exit For End If Next H
TIEU LUAN MOI download : skknchat@gmail.com
(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu
k = k + 1 Loop
If Ktra Then
DT_UV(H).Mo_ta = DT_UV(H).Mo_ta & "|" & DS_UV(i).H &
"-" & DS_UV(i).W & "|"
If DT_UV(H).X1 > DS_UV(i).W Then DT_UV(H).X1 = DS_UV(i).W
If DT_UV(H).X2 < DS_UV(i).W Then DT_UV(H).X2 = DS_UV(i).W
If DT_UV(H).Y1 > DS_UV(i).H Then DT_UV(H).Y1 = DS_UV(i).H
If DT_UV(H).Y2 < DS_UV(i).H Then DT_UV(H).Y2 = DS_UV(i).H
Else j = j + 1
ReDim Preserve DT_UV(j)
DT_UV(j).Mo_ta = "|" & DS_UV(i).H & "-" & DS_UV(i).W &
"|"
DT_UV(j).Y1 = DS_UV(i).H DT_UV(j).X1 = DS_UV(i).W DT_UV(j).Y2 = DS_UV(i).H DT_UV(j).X2 = DS_UV(i).W DT_UV(j).TT = True
End If Next i
Tim_Cac_Ung_Vien = j End Function
Public Function Tim_Cac_Doi_Tuong(MH As Integer, MW As Integer) As Integer
Dim i As Integer, j As Integer Dim SUV As Integer
Dim SDT As Integer, BD As Integer Dim Thoat As Boolean
SUV = Tim_Cac_Ung_Vien(MH, MW) If SUV = 0 Then
Tim_Cac_Doi_Tuong = 0 Exit Function
End If
(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu
If SUV = 1 Then SDT = 2
ReDim DS_DT(1)
DS_DT(1).X1 = DT_UV(1).X1 DS_DT(1).X2 = DT_UV(1).X2 DS_DT(1).Y1 = DT_UV(1).Y1 DS_DT(1).Y2 = DT_UV(1).Y2
Else
For i = 1 To SUV
If (DT_UV(i).X2 - DT_UV(i).X1 <= 1) Or (DT_UV(i).Y2 - DT_UV(i).Y1 <= 1) Then DT_UV(i).TT = False
Next i SDT = 1
For i = 1 To SUV
If DT_UV(i).TT Then BD = i
Exit For End If Next i Do
ReDim Preserve DS_DT(SDT) DS_DT(SDT).X1 = DT_UV(BD).X1 DS_DT(SDT).X2 = DT_UV(BD).X2 DS_DT(SDT).Y1 = DT_UV(BD).Y1 DS_DT(SDT).Y2 = DT_UV(BD).Y2 DT_UV(BD).TT = False
For j = SDT + 1 To SUV If DT_UV(j).TT Then
If DS_DT(SDT).X2 < (DT_UV(j).X1 - 2) Then DT_UV(j).TT = True
Else
If ((DT_UV(j).Y1 - DS_DT(SDT).Y2 <= 2) Or (DS_DT(SDT).Y2 >= DT_UV(j).Y1)) Then
If DS_DT(SDT).X1 > DT_UV(j).X1 Then DS_DT(SDT).X1 = DT_UV(j).X1
If DS_DT(SDT).X2 < DT_UV(j).X2 Then DS_DT(SDT).X2 = DT_UV(j).X2
TIEU LUAN MOI download : skknchat@gmail.com
(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu(LUAN.van.THAC.si).nghien.cuu.mot.so.phuong.phap.nhan.dang.doi.tuong.ung.dung.trong.he.thong.camera.quan.sat.bao.ve.muc.tieu
If DS_DT(SDT).Y2 < DT_UV(j).Y2 Then DS_DT(SDT).Y2 = DT_UV(j).Y2
DT_UV(j).TT = False End If
End If End If Next j
SDT = SDT + 1 For i = 1 To SUV
If DT_UV(i).TT Then BD = i
Exit For End If Next i
Thoat = False For i = 1 To SUV
Thoat = Thoat Or DT_UV(i).TT Next i
If Not Thoat Then Exit Do Loop
End If
Tim_Cac_Doi_Tuong = SDT - 1 End Function