Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opencv4 upgrade #168

Merged
merged 4 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions dense_map/geometry_mapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH})
message(STATUS "CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")

# Find OpenCV and fix a 3.3.1 bug
find_package(OpenCV 3 REQUIRED)
if (${OpenCV_VERSION} MATCHES "3.3.1")
foreach(__cvcomponent ${OpenCV_LIB_COMPONENTS})
set (__original_cvcomponent ${__cvcomponent})
if(NOT __cvcomponent MATCHES "^opencv_")
set(__cvcomponent opencv_${__cvcomponent})
endif()
if (TARGET ${__cvcomponent})
set_target_properties(${__cvcomponent} PROPERTIES
MAP_IMPORTED_CONFIG_DEBUG ""
MAP_IMPORTED_CONFIG_RELEASE ""
MAP_IMPORTED_CONFIG_RELWITHDEBINFO ""
MAP_IMPORTED_CONFIG_MINSIZEREL ""
)
endif()
endforeach(__cvcomponent)
endif()
set(OpenCV_LIBRARIES ${OpenCV_LIBS})

find_package(OpenCV 4 REQUIRED)
find_package(OpenMVG QUIET REQUIRED)

find_package(Protobuf REQUIRED)
Expand Down
12 changes: 6 additions & 6 deletions dense_map/geometry_mapper/tools/geometry_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,18 +477,18 @@ def run_cmd(cmd, log_file, verbose=False):
cmd_str = format_cmd(cmd)
print(cmd_str + "\n")

with open(log_file, "w", buffering=0) as f: # replace 'w' with 'wb' for Python 3
f.write(cmd_str + "\n")
with open(log_file, "wb", buffering=0) as f:
f.write((cmd_str + "\n").encode())
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
for line in iter(
process.stdout.readline, ""
): # replace '' with b'' for Python 3

for line in iter(process.stdout.readline, b""):
if verbose:
sys.stdout.write(line)
sys.stdout.write(line.decode())
f.write(line)

# If a certain step failed, do not continue
process.wait()

if process.returncode != 0:
print("Failed execution of: " + " ".join(cmd))
sys.exit(1)
Expand Down
17 changes: 9 additions & 8 deletions pano/pano_stitch/scripts/stitch_panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
from tf.transformations import euler_from_quaternion

RAD2DEG = 180 / math.pi
IMAGE_TOPIC = "/hw/cam_sci_info"
IMAGE_TOPIC = ["/hw/cam_sci/compressed", "/hw/cam_sci_info"]
POSE_TOPIC = "/loc/pose"
UNDISTORT_ENV_VARS = [
"ASTROBEE_RESOURCE_DIR",
Expand Down Expand Up @@ -214,8 +214,9 @@ def get_image_meta(inbag_path, images_dir, skip_images_str):
with rosbag.Bag(inbag_path) as bag:
need_pose = False
print("Detecting images:")
for topic, msg, t in bag.read_messages([IMAGE_TOPIC, POSE_TOPIC]):
if topic == IMAGE_TOPIC:
topics = IMAGE_TOPIC + [POSE_TOPIC]
for topic, msg, t in bag.read_messages(topics):
if topic in IMAGE_TOPIC:
img_path = os.path.join(
images_dir,
str(msg.header.stamp.secs)
Expand Down Expand Up @@ -426,14 +427,12 @@ def next(self):

def read_pto(pano, pto_path):
print("\nread_pto: %s" % pto_path)
ifs = hsi.ifstream(pto_path)
pano.readData(ifs)
pano.ReadPTOFile(pto_path)


def write_pto(pano, pto_path):
print("\nwrite_pto: %s" % pto_path)
ofs = hsi.ofstream(pto_path)
pano.writeData(ofs)
pano.WritePTOFile(pto_path)


def get_timestamp():
Expand Down Expand Up @@ -732,7 +731,9 @@ def main():
"Preserving final metadata %s alongside output pano image"
% os.path.basename(pto_final)
)
shutil.copyfile(pto_final, output_dir)
shutil.copyfile(
pto_final, os.path.join(output_dir, os.path.basename(pto_final))
)

print("\n=== Final stitched pano in %s ===\n" % final_png_path)

Expand Down
Loading