diff --git a/codebook/codebook_kNN.joblib b/codebook/codebook_kNN.joblib index 3b0f21e..122a3d2 100644 Binary files a/codebook/codebook_kNN.joblib and b/codebook/codebook_kNN.joblib differ diff --git a/codebook/create_codebook.py b/codebook/create_codebook.py index 6148cb6..5cac324 100755 --- a/codebook/create_codebook.py +++ b/codebook/create_codebook.py @@ -7,7 +7,7 @@ from tqdm import tqdm K = 4096 # số visual words (512–4096 tùy dữ liệu) 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 def create_detector(): diff --git a/codebook/idf.npy b/codebook/idf.npy index fd8905c..f67b48f 100644 Binary files a/codebook/idf.npy and b/codebook/idf.npy differ diff --git a/rviz/landmarks.rviz b/rviz/landmarks.rviz index 51c3e62..3fd36c5 100644 --- a/rviz/landmarks.rviz +++ b/rviz/landmarks.rviz @@ -5,7 +5,7 @@ Panels: Property Tree Widget: Expanded: ~ Splitter Ratio: 0.5 - Tree Height: 140 + Tree Height: 371 - Class: rviz/Selection Name: Selection - Class: rviz/Views @@ -49,18 +49,6 @@ Visualization Manager: Frame Timeout: 15 Frames: 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 Scale: 1 Name: TF @@ -68,15 +56,7 @@ Visualization Manager: Show Axes: true Show Names: true 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 Value: true - Class: rviz/Image @@ -151,7 +131,7 @@ Window Geometry: Height: 647 Hide Left Dock: true Hide Right Dock: false - QMainWindow State: 000000ff00000000fd00000001000000000000049b0000032efc0200000005fb000000160043006f006c006f007200200049006d006100670065000000003b000000a10000001600fffffffb000000100044006900730070006c00610079007300000000e20000010d000000c700fffffffb0000001200530065006c0065006300740069006f006e00000001f5000000830000005c00fffffffb0000000a00560069006500770073000000027e000000ad000000a000fffffffb0000000800540069006d00650000000331000000380000003800ffffff000003250000023100000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 + QMainWindow State: 000000ff00000000fd00000001000000000000049b0000032efc0200000005fb000000160043006f006c006f007200200049006d006100670065000000003b000000a10000001600fffffffb000000100044006900730070006c00610079007300000000e20000010d000000c900fffffffb0000001200530065006c0065006300740069006f006e00000001f5000000830000005c00fffffffb0000000a00560069006500770073000000027e000000ad000000a400fffffffb0000000800540069006d00650000000331000000380000003900ffffff000003250000022d00000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000 Selection: collapsed: true Time: @@ -159,5 +139,5 @@ Window Geometry: Views: collapsed: true Width: 805 - X: 2024 - Y: 269 + X: 706 + Y: 156 diff --git a/src/landmark_arm_update.py b/src/landmark_arm_update.py index 9ff9095..418bc58 100644 --- a/src/landmark_arm_update.py +++ b/src/landmark_arm_update.py @@ -24,7 +24,7 @@ from ultralytics import YOLO # from sklearn.metrics.pairwise import cosine_similarity # ===== messages -from landmarks_detection_ROS.msg import landmark, landmark_array +from landmarks_detection.msg import landmark, landmark_array # ==== Config & paths (ARM-safe defaults) diff --git a/src/landmark_update.py b/src/landmark_update.py index 7aaf065..f9f0d57 100755 --- a/src/landmark_update.py +++ b/src/landmark_update.py @@ -13,10 +13,10 @@ import joblib from collections import deque, defaultdict 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) -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) import rospkg @@ -137,7 +137,12 @@ class Memory: return self.vecs[lid] # single vector 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): """ Optional: score hợp nhất appearance + 3D + recency. """