Skip to content

Commit

Permalink
Improved protobuf message compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Dec 12, 2020
1 parent dd9e203 commit e3bd2e4
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 5,394 deletions.
39 changes: 6 additions & 33 deletions src/CMakeLists.txt
Expand Up @@ -113,13 +113,6 @@ set(OPENSHOT_CV_SOURCES
./sort_filter/Hungarian.cpp
./sort_filter/KalmanTracker.cpp)

# Compiled Protobuf messages
set(PROTOBUF_MESSAGES
stabilizedata.pb.cc
trackerdata.pb.cc
objdetectdata.pb.cc
)

# Video effects
set(EFFECTS_SOURCES
effects/Bars.cpp
Expand Down Expand Up @@ -416,37 +409,16 @@ if (OpenCV_FOUND)
message(FATAL_ERROR "\nPLEASE INSTALL PROTOBUF. Protobuf is required when compiling with opencv.\n")
endif()

# compiling protobuf messages
include_directories(${PROTOBUF_INCLUDE_DIR})
set(PROTOBUF_MESSAGES_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}/protobuf_messages")

FILE(GLOB PROTO_MSGS "${PROTOBUF_MESSAGES_FOLDER}/*.proto")
foreach(PROTO_MSG ${PROTO_MSGS})
execute_process (
COMMAND bash -c "${PROTOBUF_PROTOC_EXECUTABLE} -I=${PROTOBUF_MESSAGES_FOLDER} --cpp_out=${PROTOBUF_MESSAGES_FOLDER} ${PROTO_MSG}"
)
endforeach()

FILE(GLOB PROTO_CCS "${PROTOBUF_MESSAGES_FOLDER}/*.pb.cc")
foreach(PROTO_CC ${PROTO_CCS})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROTO_CC} ${CMAKE_CURRENT_SOURCE_DIR})
file(REMOVE ${PROTO_CC})
endforeach()

FILE(GLOB PROTO_HS "${PROTOBUF_MESSAGES_FOLDER}/*.pb.h")
foreach(PROTO_H ${PROTO_HS})
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROTO_H} ${CMAKE_CURRENT_SOURCE_DIR})
file(REMOVE ${PROTO_H})
endforeach()
add_subdirectory(protobuf_messages)

target_include_directories(openshot PUBLIC ${ProtobufMessagePath})

# Add OpenCV target sources
target_sources(openshot PRIVATE
${OPENSHOT_CV_SOURCES}
${PROTOBUF_MESSAGES})
${OPENSHOT_CV_SOURCES})

# Link libopenshot with OpenCV libs
target_link_libraries(openshot PUBLIC ${OpenCV_LIBS} ${PROTOBUF_LIBRARY})

target_link_libraries(openshot PUBLIC ProtoMessages ${OpenCV_LIBS} ${PROTOBUF_LIBRARY} ${Protobuf_INCLUDE_DIRS})
endif()

############### LINK LIBRARY #################
Expand Down Expand Up @@ -490,3 +462,4 @@ endif()
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Jonathan Thomas") #required

include(CPack)

2 changes: 1 addition & 1 deletion src/effects/ObjectDetection.h
Expand Up @@ -40,7 +40,7 @@
#include "../Color.h"
#include "../Json.h"
#include "../KeyFrame.h"
#include "../objdetectdata.pb.h"
#include "objdetectdata.pb.h"

// Struct that stores the detected bounding boxes for all the clip frames
struct DetectionData{
Expand Down

0 comments on commit e3bd2e4

Please sign in to comment.