diff --git a/CMakeLists.txt b/CMakeLists.txt index 63ba7221ec..116cd01366 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,10 +28,14 @@ ############################################################################ # Validate CMake version. -cmake_minimum_required(VERSION 3.1 FATAL_ERROR) +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) if(COMMAND CMAKE_POLICY) - cmake_policy(SET CMP0003 NEW) + cmake_policy(SET CMP0075 NEW) + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.28") + cmake_policy(SET CMP0153 OLD) + cmake_policy(SET CMP0145 OLD) + endif() endif(COMMAND CMAKE_POLICY) # Required C++ Standard. diff --git a/cmake/Architecture.cmake b/cmake/Architecture.cmake index fe77693470..fc56c409d1 100644 --- a/cmake/Architecture.cmake +++ b/cmake/Architecture.cmake @@ -43,9 +43,13 @@ macro(dune_test_cpu cpu bits endianess macro header) if(${output}) check_cxx_source_compiles("#if defined(__arch64__)\n#else\n#error not defined\n#endif\nint main(void) {return 0; }\n" __ARCH64__) + check_cxx_source_compiles("#if defined(__aarch64__)\n#else\n#error not defined\n#endif\nint main(void) {return 0; }\n" __AARCH64__) if(__ARCH64__) set(gbits 64) endif(__ARCH64__) + if(__AARCH64__) + set(gbits 64) + endif(__AARCH64__) set(DUNE_CPU 1) set(DUNE_CPU_${ucpu} 1) @@ -91,6 +95,7 @@ macro(dune_probe_cpu) dune_test_cpu(ARMv4 32 unknown __ARM_ARCH_4T__ cstdio) dune_test_cpu(ARMv5 32 unknown __ARM_ARCH_5T__ cstdio) dune_test_cpu(ARMv7 32 unknown __ARM_ARCH_7A__ cstdio) + dune_test_cpu(ARMv8 64 little __aarch64__ cstdio) dune_test_cpu(ARM 32 unknown __arm__ cstdio) dune_test_cpu(SPARC 32 big __sparc__ cstdio) dune_test_cpu(SPARCv9 64 big __sparcv9 cstdio) diff --git a/cmake/Libraries/Exiv2.cmake b/cmake/Libraries/Exiv2.cmake index f7da65c819..49ece50085 100644 --- a/cmake/Libraries/Exiv2.cmake +++ b/cmake/Libraries/Exiv2.cmake @@ -27,8 +27,8 @@ if(EXIV2) find_library(EXIV2_LIBRARY NAMES exiv2 PATHS /usr/lib) - - if(${EXIV2_LIBRARY} STRLESS "libexiv2.so") + if(${EXIV2_LIBRARY} MATCHES "libexiv2.so") + message(STATUS "Found Exiv2 library: ${EXIV2_LIBRARY}") # Exiv2 Present set(DUNE_SYS_HAS_EXIV2 1 CACHE INTERNAL "Exiv2 library") set(DUNE_USING_EXIV2 1 CACHE INTERNAL "Exiv2 library") diff --git a/cmake/Libraries/JPEG.cmake b/cmake/Libraries/JPEG.cmake index 90ab5df19d..ffb9079fd9 100644 --- a/cmake/Libraries/JPEG.cmake +++ b/cmake/Libraries/JPEG.cmake @@ -30,20 +30,11 @@ CHECK_LIBRARY_EXISTS(jpeg jpeg_set_defaults "" HAVE_LIB_JPEG) dune_test_header_deps(jpeglib.h "sys/types.h;stdio.h") -check_cxx_source_compiles(" -#include -#include -#if JPEG_LIB_VERSION < 80 -# error JPEG too old -#endif -int main(void) {return 0;}" -HAVE_LIB_JPEG_80) - -if(HAVE_LIB_JPEG AND HAVE_LIB_JPEG_80 AND DUNE_SYS_HAS_JPEGLIB_H) +if(HAVE_LIB_JPEG AND DUNE_SYS_HAS_JPEGLIB_H) dune_add_lib(jpeg) set(DUNE_SYS_HAS_JPEG 1 CACHE INTERNAL "JPEG library") set(DUNE_USING_JPEG 1 CACHE INTERNAL "JPEG library") -else(HAVE_LIB_JPEG AND HAVE_LIB_JPEG_80 AND DUNE_SYS_HAS_JPEGLIB_H) +else(HAVE_LIB_JPEG AND DUNE_SYS_HAS_JPEGLIB_H) set(DUNE_SYS_HAS_JPEG 0 CACHE INTERNAL "JPEG library") set(DUNE_USING_JPEG 0 CACHE INTERNAL "JPEG library") -endif(HAVE_LIB_JPEG AND HAVE_LIB_JPEG_80 AND DUNE_SYS_HAS_JPEGLIB_H) +endif(HAVE_LIB_JPEG AND DUNE_SYS_HAS_JPEGLIB_H) diff --git a/cmake/Libraries/OpenCV.cmake b/cmake/Libraries/OpenCV.cmake index c62e4dc582..d4aa18c1c1 100644 --- a/cmake/Libraries/OpenCV.cmake +++ b/cmake/Libraries/OpenCV.cmake @@ -28,14 +28,15 @@ ############################################################################ if(OPENCV) - CHECK_LIBRARY_EXISTS(opencv_core cvGetImage "" HAVE_LIB_OPENCV) + #find_package(OpenCV4 REQUIRED) + find_library(OPENCV_LIBRARY NAMES opencv_core PATHS /usr/lib) + if(${OPENCV_LIBRARY} MATCHES "libopencv_core.so") + # OPENCV Present + message(STATUS "Found Opencv library: ${OPENCV_LIBRARY}") + set(DUNE_SYS_HAS_OPENCV 1 CACHE INTERNAL "Opencv library") + set(DUNE_USING_OPENCV 1 CACHE INTERNAL "Opencv library") - if(HAVE_LIB_OPENCV) - # OpenCV Present - set(DUNE_SYS_HAS_OPENCV 1 CACHE INTERNAL "OpenCV library") - set(DUNE_USING_OPENCV 1 CACHE INTERNAL "OpenCV library") - - # FIND_PACKAGE(OpenCV REQUIRED) + # FIND_PACKAGE(OpenCV REQUIRED) dune_add_lib(opencv_calib3d) dune_add_lib(opencv_core) dune_add_lib(opencv_features2d) @@ -54,19 +55,13 @@ if(OPENCV) #dune_add_lib(opencv_contrib) #dune_add_lib(opencv_gpu) #dune_add_lib(opencv_legacy) + dune_add_lib(opencv_imgcodecs) - # Check Header - dune_test_header(opencv2/opencv.hpp) - - dune_test_header(opencv2/imgcodecs.hpp) - if(DUNE_SYS_HAS_OPENCV2_IMGCODECS_HPP) - dune_add_lib(opencv_imgcodecs) - endif(DUNE_SYS_HAS_OPENCV2_IMGCODECS_HPP) - - else(HAVE_LIB_OPENCV) + else() # OpenCV not found on the system. message(SEND_ERROR "OpenCV was not found on the system.") set(DUNE_SYS_HAS_OPENCV 0 CACHE INTERNAL "OpenCV library") set(DUNE_USING_OPENCV 0 CACHE INTERNAL "OpenCV library") - endif(HAVE_LIB_OPENCV) + endif() + endif(OPENCV) diff --git a/cmake/Libraries/PointGrey.cmake b/cmake/Libraries/PointGrey.cmake index eeec9f1999..cfe69c5a52 100644 --- a/cmake/Libraries/PointGrey.cmake +++ b/cmake/Libraries/PointGrey.cmake @@ -26,26 +26,21 @@ ############################################################################ if(POINTGREY) - CHECK_LIBRARY_EXISTS(flycapture-c GetInternal "" HAVE_LIB_FLYCAPTURE) - - if(HAVE_LIB_FLYCAPTURE) - # FlyCapture Present + find_library(POINTGREY_LIBRARY NAMES flycapture PATHS /usr/lib) + if(${POINTGREY_LIBRARY} MATCHES "libflycapture.so") + message(STATUS "Found Pointgrey library: ${POINTGREY_LIBRARY}") + # Flycapture Present set(DUNE_SYS_HAS_FLYCAPTURE 1 CACHE INTERNAL "FlyCapture library") set(DUNE_USING_FLYCAPTURE 1 CACHE INTERNAL "FlyCapture library") - dune_add_lib(flycapture) dune_add_lib(flycapture-c) - # Check Header - dune_test_header(flycapture/FlyCapture2.h) - dune_test_header(flycapture/FlyCapture2_C.h) - - else(HAVE_LIB_FLYCAPTURE) - # FlyCapture not found on the system. + else() + # FlyCapture not found on the system. message(SEND_ERROR "FlyCapture was not found on the system.") set(DUNE_SYS_HAS_FLYCAPTURE 0 CACHE INTERNAL "FlyCapture library") set(DUNE_USING_FLYCAPTURE 0 CACHE INTERNAL "FlyCapture library") - endif(HAVE_LIB_FLYCAPTURE) + endif() endif(POINTGREY) diff --git a/src/Vision/PointGrey/SaveImage.hpp b/src/Vision/PointGrey/SaveImage.hpp index 670be9ffa1..43bce45843 100644 --- a/src/Vision/PointGrey/SaveImage.hpp +++ b/src/Vision/PointGrey/SaveImage.hpp @@ -1,9 +1,29 @@ -/* - * SavImage.hpp - * - * Created on: May 8, 2017 - * Author: Pedro Gonçalves - */ +//*************************************************************************** +// Copyright 2007-2022 Universidade do Porto - Faculdade de Engenharia * +// Laboratório de Sistemas e Tecnologia Subaquática (LSTS) * +//*************************************************************************** +// This file is part of DUNE: Unified Navigation Environment. * +// * +// Commercial Licence Usage * +// Licencees holding valid commercial DUNE licences may use this file in * +// accordance with the commercial licence agreement provided with the * +// Software or, alternatively, in accordance with the terms contained in a * +// written agreement between you and Universidade do Porto. For licensing * +// terms, conditions, and further information contact lsts@fe.up.pt. * +// * +// European Union Public Licence - EUPL v.1.1 Usage * +// Alternatively, this file may be used under the terms of the EUPL, * +// Version 1.1 only (the "Licence"), appearing in the file LICENCE.md * +// included in the packaging of this file. You may not use this work * +// except in compliance with the Licence. Unless required by applicable * +// law or agreed to in writing, software distributed under the Licence is * +// distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF * +// ANY KIND, either express or implied. See the Licence for the specific * +// language governing permissions and limitations at * +// http://ec.europa.eu/idabc/eupl.html. * +//*************************************************************************** +// Author: Pedro Gonçalves * +//*************************************************************************** #ifndef VISION_POINTGREY_SAVEIMAGE_HPP_INCLUDED_ #define VISION_POINTGREY_SAVEIMAGE_HPP_INCLUDED_ @@ -78,7 +98,7 @@ namespace Vision { m_name_thread = name; m_new_image = false; - m_jpeg_params.push_back(CV_IMWRITE_JPEG_QUALITY); + m_jpeg_params.push_back(cv::IMWRITE_JPEG_QUALITY); m_jpeg_params.push_back(65); m_row_bytes = 0; cv::setNumThreads(1); diff --git a/src/Vision/PointGrey/Task.cmake b/src/Vision/PointGrey/Task.cmake index 5e21d7ec94..31eeee2a62 100644 --- a/src/Vision/PointGrey/Task.cmake +++ b/src/Vision/PointGrey/Task.cmake @@ -1,21 +1,20 @@ -if(POINTGREY) - if(DUNE_SYS_HAS___ARM_ARCH_7A__) - if(NOT DUNE_SYS_HAS_OPENCV) - set(TASK_ENABLED FALSE) - endif(NOT DUNE_SYS_HAS_OPENCV) +if(DUNE_SYS_HAS___ARM_ARCH_7A__ OR DUNE_SYS_HAS___AARCH64__) - if(NOT DUNE_SYS_HAS_EXIV2) - set(TASK_ENABLED FALSE) - endif(NOT DUNE_SYS_HAS_EXIV2) + if(NOT DUNE_SYS_HAS_OPENCV) + set(TASK_ENABLED FALSE) + endif(NOT DUNE_SYS_HAS_OPENCV) + + if(NOT DUNE_SYS_HAS_EXIV2) + set(TASK_ENABLED FALSE) + endif(NOT DUNE_SYS_HAS_EXIV2) - if(NOT DUNE_SYS_HAS_FLYCAPTURE) - set(TASK_ENABLED FALSE) - endif(NOT DUNE_SYS_HAS_FLYCAPTURE) - elseif(DUNE_OS_WINDOWS) + if(NOT DUNE_SYS_HAS_FLYCAPTURE) set(TASK_ENABLED FALSE) - endif(DUNE_SYS_HAS___ARM_ARCH_7A__) -else() + endif(NOT DUNE_SYS_HAS_FLYCAPTURE) + +else(DUNE_SYS_HAS___ARM_ARCH_7A__ OR DUNE_SYS_HAS___AARCH64__) set(TASK_ENABLED FALSE) -endif(POINTGREY) -set(TASK_LICENSE "Proprietary") +endif(DUNE_SYS_HAS___ARM_ARCH_7A__ OR DUNE_SYS_HAS___AARCH64__) + +set(TASK_LICENSE "Proprietary") \ No newline at end of file diff --git a/src/Vision/PointGrey/Task.cpp b/src/Vision/PointGrey/Task.cpp index 1552e690ac..27a9e261bc 100644 --- a/src/Vision/PointGrey/Task.cpp +++ b/src/Vision/PointGrey/Task.cpp @@ -37,7 +37,7 @@ // DUNE headers. #include -#if defined(DUNE_CPU_ARMV7) +#if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) //FlyCapture headers #include //Exiv2 headers @@ -111,7 +111,7 @@ namespace Vision { //! Configuration parameters Arguments m_args; - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) //! Camera object FlyCapture2::Camera m_camera; //! Structure of Camera object @@ -165,7 +165,7 @@ namespace Vision long unsigned int m_frame_cnt; //! Number of frames lost long unsigned int m_frame_lost_cnt; - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) //! Clase/thread to save image/exif data SaveImage *m_save[c_number_max_thread]; #endif @@ -351,7 +351,7 @@ namespace Vision for(int i = 0; i < c_number_max_thread; i++) { sprintf(text, "thr%d", i); - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) m_save[i] = new SaveImage(this, text); m_save[i]->start(); #endif @@ -368,7 +368,7 @@ namespace Vision m_isStartTask = true; } - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) void onResourceRelease(void) { @@ -522,7 +522,7 @@ namespace Vision inf("on Deactivation"); m_is_to_capture = false; m_isCapturing = false; - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) m_error = m_camera.StopCapture(); if ( m_error != FlyCapture2::PGRERROR_OK ) war("Error stopping camera capture: %s", m_save[m_thread_cnt]->getNameError(m_error).c_str()); @@ -590,7 +590,7 @@ namespace Vision { while (!std::feof(pipe) && !m_timeout_reading.overflow()) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) (void)std::fgets(m_buffer, sizeof(m_buffer), pipe); #endif } @@ -635,12 +635,7 @@ namespace Vision char governor[16]; std::string result = ""; FILE* pipe; - -#ifdef __GNUC__ if ((pipe = popen("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", "r")) == NULL) -#else - if (true) -#endif { war("popen() failed - set_cpu_governor!"); setEntityState(IMC::EntityState::ESTA_ERROR, Status::CODE_INTERNAL_ERROR); @@ -801,7 +796,7 @@ namespace Vision void getInfoCamera(void) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) debug("Vendor Name: %s", m_camInfo.vendorName); debug("Model Name: %s", m_camInfo.modelName); debug("Serial Number: %d", m_camInfo.serialNumber); @@ -817,7 +812,7 @@ namespace Vision bool setUpCamera(void) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) unsigned int nb_cameras; int bus_attempts = 1; while (bus_attempts <= c_max_number_attempts_bus) @@ -901,7 +896,7 @@ namespace Vision bool pollForTriggerReady(void) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) unsigned int k_softwareTrigger = 0x62C; unsigned int regVal = 0; @@ -921,7 +916,7 @@ namespace Vision bool set_shutter_value(float value) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) //Declare a Property struct. FlyCapture2::Property prop; //Define the property to adjust. @@ -952,7 +947,7 @@ namespace Vision bool fireSoftwareTrigger(void) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) const unsigned int k_softwareTrigger = 0x62C; const unsigned int k_fireVal = 0x80000000; m_error = m_camera.WriteRegister( k_softwareTrigger, k_fireVal ); @@ -968,7 +963,7 @@ namespace Vision bool getImage(void) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) bool result = false; saveInfoExif(); if(m_is_strobe) @@ -1052,7 +1047,7 @@ namespace Vision int sendImageThread(int cnt_thread) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) int pointer_cnt_thread = cnt_thread; bool jump_over = false; bool result_thread; @@ -1103,7 +1098,7 @@ namespace Vision releaseRamCached(void) { debug("Releasing cache ram."); - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) (void)std::system("sync"); (void)std::system("echo 1 > /proc/sys/vm/drop_caches"); (void)std::system("sync"); @@ -1113,7 +1108,7 @@ namespace Vision void saveInfoExif(void) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) std::memset(&m_text_exif_timestamp, '\0', sizeof(m_text_exif_timestamp)); std::sprintf(m_text_exif_timestamp, "%0.4f", Clock::getSinceEpoch()); m_back_epoch = m_text_exif_timestamp; @@ -1147,7 +1142,7 @@ namespace Vision void triggerFrame(void) { - #if defined(DUNE_CPU_ARMV7) + #if defined(DUNE_CPU_ARMV7) || defined(DUNE_CPU_ARMV8) if(!getImage() && m_is_to_capture) { war("Restarting camera...");