Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
**__pycache__
**.swp
**.pyc
**.DS_Store
uv.lock
artifacts
build
devel
Expand Down
7 changes: 5 additions & 2 deletions kamera/postflight/dat_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,11 @@ def parse_gsof_stream(buf):

def maybe_gsof(buf):
# type: (bytes) -> bool
if struct.unpack("B", buf[0:1])[0] == START_TX:
return True
try:
if struct.unpack('B', buf[0:1])[0] == START_TX:
return True
except:
pass
return False


Expand Down
70 changes: 69 additions & 1 deletion src/cams/phase_one/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,56 @@ find_package(catkin REQUIRED COMPONENTS
## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system)

## Find CUDA
find_package(CUDA QUIET)
if(CUDA_FOUND)
enable_language(CUDA)
message(STATUS "CUDA found: ${CUDA_VERSION}")
message(STATUS "CUDA libraries: ${CUDA_LIBRARIES}")
else()
message(WARNING "CUDA not found - nvjpeg will not be available")
endif()

## Find nvjpeg (part of CUDA Toolkit)
if(CUDA_FOUND)
find_library(NVJPEG_LIBRARY
NAMES nvjpeg
PATHS
${CUDA_TOOLKIT_ROOT_DIR}/lib64
${CUDA_TOOLKIT_ROOT_DIR}/lib
/usr/local/cuda/lib64
/usr/local/cuda/lib
NO_DEFAULT_PATH
)

if(NVJPEG_LIBRARY)
message(STATUS "nvjpeg library found: ${NVJPEG_LIBRARY}")
set(NVJPEG_FOUND TRUE)
else()
message(WARNING "nvjpeg library not found - nvjpeg encoding will not be available")
set(NVJPEG_FOUND FALSE)
endif()

# Find nvjpeg header
find_path(NVJPEG_INCLUDE_DIR
NAMES nvjpeg.h
PATHS
${CUDA_TOOLKIT_ROOT_DIR}/include
/usr/local/cuda/include
NO_DEFAULT_PATH
)

if(NVJPEG_INCLUDE_DIR)
message(STATUS "nvjpeg headers found: ${NVJPEG_INCLUDE_DIR}")
add_definitions(-DHAVE_NVJPEG)
else()
message(WARNING "nvjpeg headers not found")
set(NVJPEG_FOUND FALSE)
endif()
else()
set(NVJPEG_FOUND FALSE)
endif()


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
Expand Down Expand Up @@ -174,6 +224,9 @@ catkin_package(
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(include ${Boost_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
if(NVJPEG_FOUND AND NVJPEG_INCLUDE_DIR)
include_directories(${NVJPEG_INCLUDE_DIR} ${CUDA_INCLUDE_DIRS})
endif()

## Declare a C++ library
# add_library(${PROJECT_NAME}
Expand All @@ -192,7 +245,8 @@ set(SRC

# build and install the nodelet

add_library(phase_one ${SRC})
add_library(${PROJECT_NAME} ${SRC})
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
target_link_libraries(phase_one PRIVATE
Expand All @@ -201,6 +255,13 @@ target_link_libraries(phase_one PRIVATE
CameraSDK::CameraSdkCpp
ImageSDK::ImageSdkCpp
)
if(NVJPEG_FOUND)
target_link_libraries(phase_one PRIVATE
${NVJPEG_LIBRARY}
${CUDA_LIBRARIES}
${CUDA_CUDART_LIBRARY}
)
endif()

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
Expand All @@ -218,6 +279,13 @@ target_link_libraries(phase_one_standalone PRIVATE
CameraSDK::CameraSdkCpp
ImageSDK::ImageSdkCpp
)
if(NVJPEG_FOUND)
target_link_libraries(phase_one_standalone PRIVATE
${NVJPEG_LIBRARY}
${CUDA_LIBRARIES}
${CUDA_CUDART_LIBRARY}
)
endif()

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
Expand Down
7 changes: 7 additions & 0 deletions src/cams/phase_one/include/phase_one/phase_one.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ namespace phase_one
const std::string &filename,
std::string format);

// Compress JPEG using nvjpeg (GPU-accelerated)
bool compressJpegNvjpeg(const cv::Mat& bgr_image,
std::vector<unsigned char>& output,
int quality = 90);

// Fill in the entries of the maps 'property_to_id_' and 'property_to_type_' given
// a 'camera' handle. These maps define the values used for setting/getting the
// parameters in the ROS service calls
Expand Down Expand Up @@ -135,6 +140,8 @@ namespace phase_one
std::string effort;
std::string project;
std::string base_dir;
std::string to_process_filename_;
std::string processed_filename_;
double auto_trigger_rate_;
int num_threads_;
// Internal data structures / sync structures
Expand Down
Loading