Skip to content

Commit d2d1ddb

Browse files
Rename folder for human understand
Delete not need files Prepare file to ease study for student Added Matlab's file
1 parent 5a07d2a commit d2d1ddb

File tree

92 files changed

+297481
-446
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+297481
-446
lines changed

.gitignore

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
# created by virtualenv automatically
22

3-
/Lab4/cpp/cv/.vs/*
3+
AlgorithmCanni/cpp/cv/.vs
4+
AlgorithmCanni/cpp/cv/Debug
5+
AlgorithmCanni/cpp/cv/x64
6+
AlgorithmCanni/cpp/cv/cv.sln
7+
AlgorithmCanni/cpp/cv/cv.vcxproj
8+
AlgorithmCanni/cpp/cv/cv.vcxproj.filters
9+
AlgorithmCanni/cpp/cv/cv.vcxproj.user
410
.idea/*
511
movies/*
612
imgs/*
7-
Lab4/cpp/cv/Debug/*
13+
AlgorithmCanni/cpp/cv/Debug/*
14+
venv
15+
Detectros/DATASET_TRAIN
16+
Detectros/Hands.zip
17+
Detectros/imageLabelingSession.mat
18+
Detectros/tra.png
19+
Detectros/Screenshot 2023-12-06 150229.png
20+
Detectros/Matlabl/SSD/resnet-50
21+
Detectros/Matlabl/SSD/ExtraData.mat
22+
Detectros/Matlabl/SSD/detector.mat

Lab4/mis1.py renamed to AlgorithmCanni/caclCanni.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,39 @@
1212
[0, 0, 0],
1313
[-1, -2, -1]
1414
])
15+
16+
# matrGx = np.array([
17+
# [-1, -1, -1],
18+
# [0, 0, 0],
19+
# [1, 1, 1]
20+
# ])
21+
#
22+
# matrGy = np.array([
23+
# [-1, 0, 1],
24+
# [-1, 0, 1],
25+
# [-1, 0, 1]
26+
# ])
27+
28+
29+
# matrGx = np.array([
30+
# [0, -1],
31+
# [1, 0],
32+
# ])
33+
#
34+
# matrGy = np.array([
35+
# [-1, 0],
36+
# [0, 1],
37+
# ])
38+
1539
def nothing(x):
1640
pass
1741

1842
cv2.namedWindow('res')
1943
cv2.createTrackbar('min','res',0,25,nothing)
2044
cv2.createTrackbar('max','res',0,25,nothing)
2145

22-
def changeSizeImg(img):
23-
scale_percent = 50 # percent of original size
46+
def changeSizeImgPercent(img,percent=50):
47+
scale_percent = percent
2448
width = int(img.shape[1] * scale_percent / 100)
2549
height = int(img.shape[0] * scale_percent / 100)
2650
dim = (width, height)
@@ -63,7 +87,7 @@ def non_max_suppression(grad_len, directionsVeryFastChangeFunc):
6387
if angle < 0:
6488
angle += 180
6589

66-
#хранения значений интенсивности пикселей в двух соседних пикселях относительно текущего пикселя
90+
#storing pixel intensity values in two neighboring pixels relative to the current pixel
6791
intensities_neighbor,intensities_neighbor2 = get_intesitiesNeighbors(
6892
grad_len[i, j + 1], grad_len[i, j - 1],
6993
grad_len[i - 1, j],grad_len[i + 1, j],
@@ -102,40 +126,31 @@ def double_thresh_filter(nms, low_border, high_border):
102126

103127
img_hsv= cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
104128
img_gray = cv2.cvtColor(img_hsv, cv2.COLOR_BGRA2GRAY)
105-
img = changeSizeImg(img_gray)
129+
img = changeSizeImgPercent(img_gray)
106130

107131
img_hsv_gray_gauss = cv2.GaussianBlur(img, (13, 13), 0.2)
108132

109-
#cv2.imshow("Blur",img)
110-
111133
calc_grad_x = cv2.Sobel(img_hsv_gray_gauss,cv2.CV_64F,1,0,ksize=3)
112134
calc_grad_y = cv2.Sobel(img_hsv_gray_gauss,cv2.CV_64F,0,1,ksize=3)
113135

114-
# cv2.imshow("GradX", calc_grad_x)
115-
#cv2.imshow("GradY", calc_grad_y)
116-
#print(calc_grad_y)
117-
#print(calc_grad_x)
118136
grad_len = np.sqrt(calc_grad_y**2.0 + calc_grad_x**2.0)
119137
grad_angle = np.arctan2(calc_grad_y,calc_grad_x)
120-
#print(grad_len)
121-
#print(grad_angle)
122138

123139
nms = non_max_suppression(grad_len,grad_angle)
124-
# cv2.imshow('NMS',nms)
125140

126141
while (1):
127142
if cv2.waitKey(1) & 0xFF == 27:
128143
break
129144
maxVal = cv2.getTrackbarPos('max', 'res')
130145
minVal = cv2.getTrackbarPos('min', 'res')
131-
canny = double_thresh_filter(nms, minVal * 10, maxVal * 10)
146+
canny = double_thresh_filter(nms, minVal * 1, maxVal * 10)
132147
cv2.imshow('res', canny)
133148
#canny_img = hysteresis_thresholding(nms,45,255) #(10,200)
134149
#cv2.imshow('GRAY', img)
135150
#cv2.imshow('GRAY', canny_img)
136151
#cv2.waitKey(0)
137152
cv2.destroyAllWindows()
138153

139-
#cv2.CV_64F: Тип данных, в котором хранятся результаты вычислений (64-битное число с плавающей запятой).
140-
#1: Порядок производной по горизонтали (горизонтальный градиент).
141-
#0: Порядок производной по вертикали (вертикальный градиент).
154+
#cv2.CV_64F: Data type in which the results of calculations are stored (64-bit floating point number).
155+
#1: The order of the horizontal derivative (horizontal gradient).
156+
#0: The order of the derivative along the vertical (vertical gradient).
File renamed without changes.

Lab4/cpp/cv/cv.cpp renamed to AlgorithmCanni/cpp/cv/cv.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int main()
101101
}
102102

103103
cvtColor(img, img, COLOR_BGR2HSV);
104-
/* извлекает синий цветовой канал из изображения img и заменяет исходное изображение img на извлеченный синий канал.*/
104+
/* Extracts the blue color channel from the img image and replaces the original img image with the extracted blue channel.*/
105105
extractChannel(img, img, 2);
106106
resize(img, img,{ 500, 500 }, 0, 0, cv::INTER_NEAREST);
107107

@@ -118,19 +118,16 @@ int main()
118118
magnitude(sobelX, sobelY, gradLen);
119119
phase(sobelX, sobelY, gradientAngle);
120120

121-
/* создается новая матрица (изображение) с размерами и типом данных, все пиксели =0 */
121+
/* a new matrix (image) is created with dimensions and data type, all pixels =0 */
122122
Mat nmsImage = Mat::zeros(gradLen.size(), gradLen.type());
123-
/*ширину и высоту матрицы., тип данных формат хранения цвета и точности пикселей*/
123+
/*width and height of the matrix., data type storage format color and pixel precision*/
124124

125125
non_maximal(nmsImage, gradLen, gradientAngle);
126126

127127
Mat cannyImage = Mat::zeros(nmsImage.size(), nmsImage.type());
128128

129129
double_thresh_filter(cannyImage, nmsImage);
130130

131-
132-
133-
// Отобразите результат
134131
imshow("Canny Edge Detection", cannyImage);
135132
waitKey(0);
136133
destroyAllWindows();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)