I am trying to run ORB SLAM 2 with frames being published of a video I need to map however all parameters I have tried have lead to no features being detected even with some aggressive parameters as seen below.
<param name="/ORBextractor/nFeatures" type="int" value="15000" />
<param name="/ORBextractor/scaleFactor" type="double" value="1.2" />
<param name="/ORBextractor/nLevels" type="int" value="8" />
<param name="/ORBextractor/iniThFAST" type="int" value="5" />
<param name="/ORBextractor/minThFAST" type="int" value="5" />
<!-- Camera parameters -->
<param name="camera_fps" type="int" value="30" />
<param name="camera_rgb_encoding" type="bool" value="true" />
<!-- Camera calibration parameters -->
<param name="load_calibration_from_cam" type="bool" value="false" />
<param name="camera_fx" type="double" value="2799.99859" />
<param name="camera_fy" type="double" value="2811.88363" />
<param name="camera_cx" type="double" value="952.780012" />
<param name="camera_cy" type="double" value="2047.51978" />
<param name="camera_k1" type="double" value="0.326744365" />
<param name="camera_k2" type="double" value="-3.60095865" />
<param name="camera_p1" type="double" value="0.00283347289" />
<param name="camera_p2" type="double" value="-0.0137430999" />
<param name="camera_k3" type="double" value="15.5250577" />
The frames do have a bit of motion blur and arent in the best of conditions but I need to be able to run a map of this video. Below I have the current publisher for the images.
#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Image
from cv_bridge import CvBridge
import cv2
import os
def advanced_enhance_image(image):
# Convert to LAB color space for better brightness/contrast manipulation
lab = cv2.cvtColor(image, cv2.COLOR_BGR2LAB)
# Apply CLAHE to the L-channel
l, a, b = cv2.split(lab)
clahe = cv2.createCLAHE(clipLimit=3.0, tileGridSize=(8, 8))
cl = clahe.apply(l)
limg = cv2.merge((cl, a, b))
# Convert back to BGR
enhanced_img = cv2.cvtColor(limg, cv2.COLOR_LAB2BGR)
# Apply unsharp mask to enhance edges
gaussian = cv2.GaussianBlur(enhanced_img, (0, 0), 3)
unsharp_image = cv2.addWeighted(enhanced_img, 1.5, gaussian, -0.5, 0)
return unsharp_image
def image_publisher():
rospy.init_node('image_publisher', anonymous=True)
image_pub = rospy.Publisher('/camera/rgb/image_raw', Image, queue_size=10)
bridge = CvBridge()
frame_path = '/home/jack/Desktop/output_frames'
enhanced_frame_path = '/home/jack/Desktop/enhanced_frames'
frame_files = sorted([f for f in os.listdir(frame_path) if f.endswith('.jpg')])
rate = rospy.Rate(30)
for frame_file in frame_files:
img = cv2.imread(os.path.join(frame_path, frame_file))
if img is not None:
enhanced_img = advanced_enhance_image(img)
# rospy.loginfo("Publishing adjusted image: {}".format(frame_file))
image_msg = bridge.cv2_to_imgmsg(enhanced_img, encoding="bgr8")
image_pub.publish(image_msg)
cv2.imwrite(os.path.join(enhanced_frame_path, frame_file), enhanced_img)
else:
rospy.logerr("Failed to read image file: {}".format(frame_file))
rate.sleep()
if __name__ == '__main__':
try:
image_publisher()
except rospy.ROSInterruptException:
pass
Below is the original input frame. can provide link to full folder containing all frames.
Below is the same output frame but "enhanced" but I would argue is worse but been told otherwise.