Closed thanggnguyenn closed 1 year ago
Thư mục main, file HOG_CPU:
(second_bin*self.sbins - first_bin*self.sbins)) (dòng 70)
((self.direction[cur_r][cur_c] - first_bin*self.sbins)/(second_bin*self.sbins - first_bin*self.sbins))
(dòng 77)
tui nghĩ dòng này chỉ cần self.sbins là được rồi tại second_bin - first_bin = 1
mà.
HOG_CPU thì đâu cần import dòng này from numba import cuda
Thư mục main file HOG_CUDA:
` for i in range(self.n_block[0]):
for j in range(self.n_block[1]):
l2[i][j] = math.sqrt(np.sum(np.square(self.hist[i:i+2, j:j+2]))) (dòng 152 --> 154)`
chỗ này tui chạy bị tràn số, không biết mấy ông có bị tràn số không?
Thư mục main, file HOG_CPU:
`self.direction = np.mod(np.add(360, np.rad2deg(np.arctan2(np.array(gradient_y), np.array(gradient_x)))), 360)` (dòng 43)
Cho tui hỏi là tại sao mình dùng số 360 vậy, tui thấy trong bài này người ta chỉ dùng tới 180 thôi.
the angles are between 0 and 180 degrees instead of 0 to 360 degrees. These are called “unsigned” gradients because a gradient and it’s negative are represented by the same numbers. In other words, a gradient arrow and the one 180 degrees opposite to it are considered the same. But, why not use the 0 – 360 degrees ? Empirically it has been shown that unsigned gradients work better than signed gradients for pedestrian detection. Some implementations of HOG will allow you to specify if you want to use signed gradients.
trong link này có nói nè: https://learnopencv.com/histogram-of-oriented-gradients/
Vì khi tính arctan có thể ra negative angle, nên cần cộng 360 để lấy positive angle. Và bản thân nội dung bài viết (https://learnopencv.com/histogram-of-oriented-gradients/) đang có mâu thuẫn rất lớn khi nói không dùng 0 - 360 nhưng lại dùng thư viện opencv phương thức CartToPolar để tính angles trong khi hàm đó theo documents viết thì kết quả nằm trong khoảng 0 - 360
HOG_CPU thì đâu cần import dòng này
from numba import cuda
Chỗ này mình copy paste mấy thư viện cho lẹ, mình sẽ chỉnh sửa lại.
Thư mục main, file HOG_CPU:
(second_bin*self.sbins - first_bin*self.sbins)) (dòng 70)
((self.direction[cur_r][cur_c] - first_bin*self.sbins)/(second_bin*self.sbins - first_bin*self.sbins))
(dòng 77)tui nghĩ dòng này chỉ cần self.sbins là được rồi tại
second_bin - first_bin = 1
mà.
Chỗ này có thể rút gọn được, mình đang chỉnh lại.
Thư mục main, file HOG_CPU:
`self.direction = np.mod(np.add(360, np.rad2deg(np.arctan2(np.array(gradient_y), np.array(gradient_x)))), 360)` (dòng 43)
Cho tui hỏi là tại sao mình dùng số 360 vậy, tui thấy trong bài này người ta chỉ dùng tới 180 thôi.
the angles are between 0 and 180 degrees instead of 0 to 360 degrees. These are called “unsigned” gradients because a gradient and it’s negative are represented by the same numbers. In other words, a gradient arrow and the one 180 degrees opposite to it are considered the same. But, why not use the 0 – 360 degrees ? Empirically it has been shown that unsigned gradients work better than signed gradients for pedestrian detection. Some implementations of HOG will allow you to specify if you want to use signed gradients.
trong link này có nói nè: https://learnopencv.com/histogram-of-oriented-gradients/
Ô check link này nha. Link này có đính kèm trong bài viết t gửi ô lúc trc á. https://lilianweng.github.io/posts/2017-10-29-object-recognition-part-1/. 360 hay 180 đều dùng được và tùy vào kinh nghiệm lựa chọn. Thường thì gradient có dấu sẽ chọn 360. Gradient không dấu thì chọn 180.
Thư mục main, file HOG_CPU:
(second_bin*self.sbins - first_bin*self.sbins)) (dòng 70)
((self.direction[cur_r][cur_c] - first_bin*self.sbins)/(second_bin*self.sbins - first_bin*self.sbins))
(dòng 77)tui nghĩ dòng này chỉ cần self.sbins là được rồi tại
second_bin - first_bin = 1
mà.
Ví dụ khoảng 0-360. Direction = 350 thì nó nằm trong bin 8 với 0. Chứ không nằm trong bin 8 với 9. Nên là k phải lúc nào second - first cũng = 1 nha
Cảm ơn mọi người nha
Thư mục main, file HOG_CPU:
Cho tui hỏi là tại sao mình dùng số 360 vậy, tui thấy trong bài này người ta chỉ dùng tới 180 thôi.
the angles are between 0 and 180 degrees instead of 0 to 360 degrees. These are called “unsigned” gradients because a gradient and it’s negative are represented by the same numbers. In other words, a gradient arrow and the one 180 degrees opposite to it are considered the same. But, why not use the 0 – 360 degrees ? Empirically it has been shown that unsigned gradients work better than signed gradients for pedestrian detection. Some implementations of HOG will allow you to specify if you want to use signed gradients.
trong link này có nói nè: https://learnopencv.com/histogram-of-oriented-gradients/