This commit is contained in:
trung09122002
2025-10-22 10:46:54 +07:00
parent a213dab29f
commit af2a1ab177
6 changed files with 15 additions and 30 deletions

Binary file not shown.

View File

@@ -7,7 +7,7 @@ from tqdm import tqdm
K = 4096 # số visual words (512–4096 tùy dữ liệu) K = 4096 # số visual words (512–4096 tùy dữ liệu)
MAX_FEATS_PER_IMG = 800 MAX_FEATS_PER_IMG = 800
IMG_GLOB = "../dataset/train/images/*.jpg" # thư mục ảnh landmark IMG_GLOB = "/home/robotics/landmark_ws/src/landmarks_detection_ROS/dataset/train/images/*.jpg" # thư mục ảnh landmark
USE_SURF = False # True nếu bạn có opencv-contrib và chấp nhận license SURF USE_SURF = False # True nếu bạn có opencv-contrib và chấp nhận license SURF
def create_detector(): def create_detector():

Binary file not shown.

View File

@@ -5,7 +5,7 @@ Panels:
Property Tree Widget: Property Tree Widget:
Expanded: ~ Expanded: ~
Splitter Ratio: 0.5 Splitter Ratio: 0.5
Tree Height: 140 Tree Height: 371
- Class: rviz/Selection - Class: rviz/Selection
Name: Selection Name: Selection
- Class: rviz/Views - Class: rviz/Views
@@ -49,18 +49,6 @@ Visualization Manager:
Frame Timeout: 15 Frame Timeout: 15
Frames: Frames:
All Enabled: true All Enabled: true
camera_aligned_depth_to_color_frame:
Value: true
camera_color_frame:
Value: true
camera_color_optical_frame:
Value: true
camera_depth_frame:
Value: true
camera_depth_optical_frame:
Value: true
camera_link:
Value: true
Marker Alpha: 1 Marker Alpha: 1
Marker Scale: 1 Marker Scale: 1
Name: TF Name: TF
@@ -68,15 +56,7 @@ Visualization Manager:
Show Axes: true Show Axes: true
Show Names: true Show Names: true
Tree: Tree:
camera_link: {}
camera_aligned_depth_to_color_frame:
camera_color_optical_frame:
{}
camera_color_frame:
{}
camera_depth_frame:
camera_depth_optical_frame:
{}
Update Interval: 0 Update Interval: 0
Value: true Value: true
- Class: rviz/Image - Class: rviz/Image
@@ -151,7 +131,7 @@ Window Geometry:
Height: 647 Height: 647
Hide Left Dock: true Hide Left Dock: true
Hide Right Dock: false Hide Right Dock: false
QMainWindow State: 000000ff00000000fd00000001000000000000049b0000032efc0200000005fb000000160043006f006c006f007200200049006d006100670065000000003b000000a10000001600fffffffb000000100044006900730070006c00610079007300000000e20000010d000000c700fffffffb0000001200530065006c0065006300740069006f006e00000001f5000000830000005c00fffffffb0000000a00560069006500770073000000027e000000ad000000a000fffffffb0000000800540069006d00650000000331000000380000003800ffffff000003250000023100000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 QMainWindow State: 000000ff00000000fd00000001000000000000049b0000032efc0200000005fb000000160043006f006c006f007200200049006d006100670065000000003b000000a10000001600fffffffb000000100044006900730070006c00610079007300000000e20000010d000000c900fffffffb0000001200530065006c0065006300740069006f006e00000001f5000000830000005c00fffffffb0000000a00560069006500770073000000027e000000ad000000a400fffffffb0000000800540069006d00650000000331000000380000003900ffffff000003250000022d00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
Selection: Selection:
collapsed: true collapsed: true
Time: Time:
@@ -159,5 +139,5 @@ Window Geometry:
Views: Views:
collapsed: true collapsed: true
Width: 805 Width: 805
X: 2024 X: 706
Y: 269 Y: 156

View File

@@ -24,7 +24,7 @@ from ultralytics import YOLO
# from sklearn.metrics.pairwise import cosine_similarity # from sklearn.metrics.pairwise import cosine_similarity
# ===== messages # ===== messages
from landmarks_detection_ROS.msg import landmark, landmark_array from landmarks_detection.msg import landmark, landmark_array
# ==== Config & paths (ARM-safe defaults) # ==== Config & paths (ARM-safe defaults)

View File

@@ -13,10 +13,10 @@ import joblib
from collections import deque, defaultdict from collections import deque, defaultdict
from ultralytics import YOLO from ultralytics import YOLO
from sklearn.metrics.pairwise import cosine_similarity # from sklearn.metrics.pairwise import cosine_similarity # Thay thế bằng numpy
# ===== messages (giữ đúng package/msg bạn đang dùng) # ===== messages (giữ đúng package/msg bạn đang dùng)
from landmarks_detection_ROS.msg import landmark, landmark_array from landmarks_detection.msg import landmark, landmark_array
# ==== Config & paths (giữ logic gốc, thêm param mới) # ==== Config & paths (giữ logic gốc, thêm param mới)
import rospkg import rospkg
@@ -137,7 +137,12 @@ class Memory:
return self.vecs[lid] # single vector return self.vecs[lid] # single vector
def _cosine(self, a, b): def _cosine(self, a, b):
return float(cosine_similarity(a.reshape(1,-1), b.reshape(1,-1))[0,0]) # Thay thế sklearn cosine_similarity bằng numpy thuần túy
a_norm = np.linalg.norm(a)
b_norm = np.linalg.norm(b)
if a_norm == 0 or b_norm == 0:
return 0.0
return float(np.dot(a, b) / (a_norm * b_norm))
def _spatial_score(self, sim, xyz, lid): def _spatial_score(self, sim, xyz, lid):
""" Optional: score hợp nhất appearance + 3D + recency. """ """ Optional: score hợp nhất appearance + 3D + recency. """