From 3de42577c1bade55a607d6cbd0c14a74fed18476 Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Wed, 15 Aug 2018 17:25:51 +0300 Subject: [PATCH] Clang tidy (fix/suppress) (#714) * bin/jenkins.sh: Use 'travis_wait' * clang-tidy: Treat warnings as errors * Suppress some third party clang-tidy warnings * bin/jenkins.sh: Use 'travis_wait' * Fix some clang-tidy warnings * clang-tidy: Fix 'modernize-use-using' warnings * clang-tidy: Fix 'performance-type-promotion-in-math-fn' warning * clang-tidy: Disable 'cppcoreguidelines-pro-bounds-pointer-arithmetic' checks * clang-tidy: Disable 'cppcoreguidelines-pro-type-vararg' checks * clang-tidy: Disable 'cppcoreguidelines-pro-bounds-array-to-pointer-decay' checks * clang-tidy: Disable 'cppcoreguidelines-pro-bounds-constant-array-index' checks * clang-tidy: Disable 'cert-flp30-c' checks * clang-tidy: Fix/suppress 'performance-noexcept-move-constructor' warnings * clang-tidy: Fix/suppress 'cppcoreguidelines-special-member-functions' warnings * clang-tidy: Disable 'cert-err58-cpp' checks * clang-tidy: Disable 'cppcoreguidelines-pro-type-union-access' checks * clang-tidy: Disable 'clang-analyzer-optin.performance.Padding' checks * clang-tidy: Disable 'cppcoreguidelines-pro-type-const-cast' checks * clang-tidy: Disable 'cppcoreguidelines-owning-memory' checks * clang-tidy: Fix/suppress warnings * clang-tidy: Use DRISHTI_BUILD_SHARED_SDK=OFF * Add clang-tidy testing * Remove '--verbose' instead of using '--discard 10 --tail 200' * clang-tidy: Disable 'cert-err60-cpp' checks * Fix Visual Studio build * Fix Visual Studio tests * Suppress clang-tidy warning * Use 'clang-tidy-libcxx' toolchain --- .clang-tidy | 17 +- .travis.yml | 7 + bin/jenkins.sh | 19 +- src/app/dlib/eyexml.cpp | 18 +- src/app/dlib/test_shape_predictor.cpp | 2 +- src/app/eye/eye.cpp | 15 ++ src/app/facecrop/FaceJitterer.h | 7 + src/app/facecrop/facecrop.cpp | 170 ++++++++++-------- src/app/fddb/FDDB.h | 2 +- src/app/fddb/fddbcrop.cpp | 52 +++--- src/app/landmarks/BIOID.cpp | 2 +- src/app/landmarks/DlibXML.h | 13 +- src/app/landmarks/HELEN.cpp | 2 +- src/app/landmarks/LFW.cpp | 2 +- src/app/landmarks/MUCT.cpp | 2 +- src/app/landmarks/TWO.cpp | 2 +- src/app/videoio/VideoSinkCV.h | 6 + src/app/videoio/VideoSourceCV.cpp | 6 + src/app/videoio/VideoSourceCV.h | 5 + src/app/videoio/VideoSourceStills.cpp | 21 ++- src/app/videoio/VideoSourceStills.h | 10 +- src/app/videoio/VideoSourceTest.cpp | 2 +- .../lib/facefilter/renderer/Context.cpp | 7 +- .../lib/facefilter/renderer/Context.h | 24 ++- .../renderer/FaceTrackerFactoryJson.cpp | 2 +- .../facefilter/renderer/FaceTrackerTest.cpp | 11 +- .../lib/facefilter/renderer/FaceTrackerTest.h | 5 + .../lib/facefilter/renderer/Renderer.h | 6 + src/lib/drishti/core/Field.h | 12 +- src/lib/drishti/core/LazyParallelResource.h | 8 +- src/lib/drishti/core/Logger.cpp | 4 +- src/lib/drishti/core/Parallel.h | 20 ++- src/lib/drishti/core/Shape.cpp | 2 +- src/lib/drishti/core/ThreadPool.h | 5 +- src/lib/drishti/core/ThrowAssert.h | 8 +- src/lib/drishti/core/arithmetic.cpp | 4 +- src/lib/drishti/core/hungarian.cpp | 4 +- src/lib/drishti/core/infix_iterator.h | 2 +- src/lib/drishti/core/scope_guard.h | 5 +- src/lib/drishti/core/timing.h | 5 +- src/lib/drishti/core/ut/test-drishti-core.cpp | 2 +- src/lib/drishti/drishti/Array.hpp | 32 ++-- src/lib/drishti/drishti/Context.hpp | 17 +- src/lib/drishti/drishti/Eye.hpp | 5 + src/lib/drishti/drishti/EyeDetector.cpp | 7 +- src/lib/drishti/drishti/EyeDetector.hpp | 8 +- src/lib/drishti/drishti/EyeIO.cpp | 2 +- src/lib/drishti/drishti/EyeSegmenter.hpp | 7 +- src/lib/drishti/drishti/EyeSegmenterImpl.hpp | 8 +- src/lib/drishti/drishti/FaceMonitorAdapter.h | 7 +- src/lib/drishti/drishti/FaceTracker.hpp | 11 +- src/lib/drishti/drishti/Image.hpp | 14 +- src/lib/drishti/drishti/Sensor.cpp | 5 +- src/lib/drishti/drishti/Sensor.hpp | 7 +- .../drishti/drishti/ut/test-EyeSegmenter.cpp | 43 ++--- .../drishti/drishti/ut/test-FaceTracker.cpp | 26 ++- src/lib/drishti/eye/Eye.h | 6 + src/lib/drishti/eye/EyeModelEstimator.h | 11 +- src/lib/drishti/eye/EyeModelEstimatorImpl.h | 7 +- src/lib/drishti/eye/EyeModelIris.cpp | 3 +- src/lib/drishti/eye/EyeModelPupil.cpp | 2 +- src/lib/drishti/eye/gpu/EyeWarp.h | 5 +- src/lib/drishti/eye/ut/test-drishti-eye.cpp | 45 ++--- src/lib/drishti/face/Face.h | 6 + src/lib/drishti/face/FaceDetector.cpp | 9 +- src/lib/drishti/face/FaceDetector.h | 23 ++- .../drishti/face/FaceDetectorAndTrackerImpl.h | 5 + .../drishti/face/FaceDetectorAndTrackerNN.h | 6 + src/lib/drishti/face/FaceTracker.h | 8 +- src/lib/drishti/face/gpu/EyeFilter.h | 5 + .../drishti/face/gpu/MultiTransformProc.cpp | 2 +- src/lib/drishti/face/gpu/MultiTransformProc.h | 5 + src/lib/drishti/face/ut/test-drishti-face.cpp | 15 +- src/lib/drishti/geometry/Cylinder.h | 5 + src/lib/drishti/geometry/Ellipse.h | 13 +- src/lib/drishti/geometry/Mesh3D.h | 6 +- src/lib/drishti/geometry/Primitives.cpp | 2 +- src/lib/drishti/geometry/conicPar2Cen.cpp | 5 +- .../geometry/ut/test-drishti-geometry.cpp | 2 +- src/lib/drishti/graphics/GLTexture.h | 5 + src/lib/drishti/hci/FaceFinder.h | 7 +- src/lib/drishti/hci/FaceFinderPainter.cpp | 5 + src/lib/drishti/hci/FaceFinderPainter.h | 6 + src/lib/drishti/hci/gpu/BlobFilter.h | 5 + src/lib/drishti/hci/gpu/FacePainter.cpp | 2 +- src/lib/drishti/hci/gpu/FacePainter.h | 5 + src/lib/drishti/hci/gpu/GLPrinter.h | 5 + src/lib/drishti/hci/gpu/VeraFont_16_2048.h | 12 +- src/lib/drishti/hci/ut/FaceMonitorHCITest.h | 4 +- src/lib/drishti/hci/ut/test-drishti-hci.cpp | 16 +- src/lib/drishti/ml/ObjectDetector.h | 9 + src/lib/drishti/ml/ObjectDetectorACF.h | 17 +- src/lib/drishti/ml/PCA.h | 11 ++ src/lib/drishti/ml/RTEShapeEstimatorImpl.h | 5 + .../ml/RegressionTreeEnsembleShapeEstimator.h | 9 +- src/lib/drishti/ml/ShapeEstimator.h | 7 + src/lib/drishti/ml/XGBooster.h | 5 + src/lib/drishti/ml/XGBoosterImpl.h | 7 +- src/lib/drishti/ml/shape_predictor.h | 11 +- src/lib/drishti/ml/ut/test-drishti-ml.cpp | 10 +- src/lib/drishti/rcpr/CPR.cpp | 2 +- src/lib/drishti/rcpr/CPR.h | 10 +- src/lib/drishti/rcpr/Vector1d.h | 2 +- src/lib/drishti/rcpr/poseGt.cpp | 2 +- 104 files changed, 745 insertions(+), 347 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 03475b78..1a5d5571 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,10 +1,21 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,google-readability-casting,misc-*,-misc-incorrect-roundings,-misc-macro-parentheses,-misc-misplaced-widening-cast,-misc-static-assert,modernize-*,-modernize-deprecated-headers,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-return-braced-init-list,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-default,-modernize-use-equals-delete,-modernize-use-noexcept,-modernize-use-transparent-functors,-modernize-use-using,performance-*,-performance-inefficient-string-concatenation,readability-*,-readability-function-size,-readability-identifier-naming,-readability-implicit-bool-cast,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter,-readability-redundant-declaration,-readability-redundant-member-init,-readability-simplify-boolean-expr,,-*,clang-analyzer-*,-clang-analyzer-alpha*,performance-*,cppcoreguidelines-*,cert-*,modernize-*' -WarningsAsErrors: '' +# TODO (?): cppcoreguidelines-pro-bounds-pointer-arithmetic +# TODO (?): cppcoreguidelines-pro-type-vararg +# TODO (?): cppcoreguidelines-pro-bounds-array-to-pointer-decay +# TODO (?): cppcoreguidelines-pro-bounds-constant-array-index +# TODO (?): cert-flp30-c +# TODO (?): cert-err58-cpp +# TODO (?): cppcoreguidelines-pro-type-union-access +# TODO (?): clang-analyzer-optin.performance.Padding +# TODO (?): cppcoreguidelines-pro-type-const-cast +# TODO (?): cppcoreguidelines-owning-memory +# TODO (?): cert-err60-cpp +Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,google-readability-casting,misc-*,-misc-incorrect-roundings,-misc-macro-parentheses,-misc-misplaced-widening-cast,-misc-static-assert,modernize-*,-modernize-deprecated-headers,-modernize-pass-by-value,-modernize-raw-string-literal,-modernize-return-braced-init-list,-modernize-use-auto,-modernize-use-default-member-init,-modernize-use-emplace,-modernize-use-equals-default,-modernize-use-equals-delete,-modernize-use-noexcept,-modernize-use-transparent-functors,-modernize-use-using,performance-*,-performance-inefficient-string-concatenation,readability-*,-readability-function-size,-readability-identifier-naming,-readability-implicit-bool-cast,-readability-inconsistent-declaration-parameter-name,-readability-named-parameter,-readability-redundant-declaration,-readability-redundant-member-init,-readability-simplify-boolean-expr,,-*,clang-analyzer-*,-clang-analyzer-alpha*,performance-*,cppcoreguidelines-*,cert-*,modernize-*,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,-cert-flp30-c,-cert-err58-cpp,-cppcoreguidelines-pro-type-union-access,-clang-analyzer-optin.performance.Padding,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-owning-memory,-cert-err60-cpp' +WarningsAsErrors: '*' HeaderFilterRegex: '.*' AnalyzeTemporaryDtors: false User: dhirvonen -CheckOptions: +CheckOptions: - key: cert-dcl59-cpp.HeaderFileExtensions value: h,hh,hpp,hxx - key: cert-err09-cpp.CheckThrowTemporaries diff --git a/.travis.yml b/.travis.yml index 5c0c7f9d..7c0c550a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,13 @@ matrix: # INSTALL=--strip # TYPE=polly + - os: linux + env: > + TOOLCHAIN=clang-tidy-libcxx + CONFIG=Release + INSTALL=--strip + TYPE=polly + - os: linux env: > TOOLCHAIN=android-ndk-r17-api-24-arm64-v8a-clang-libcxx14 diff --git a/bin/jenkins.sh b/bin/jenkins.sh index abb02c14..64793d71 100755 --- a/bin/jenkins.sh +++ b/bin/jenkins.sh @@ -67,11 +67,12 @@ case "${TYPE}" in fi fi - if [[ "${TOOLCHAIN}" == "clang-tidy" ]]; + if [[ "${TOOLCHAIN}" == "clang-tidy-libcxx" ]]; then + SHARED_SDK=OFF if [[ "${TRAVIS}" == "true" ]]; then - POLLY_DISCARD_OPTIONS="--discard 10 --tail 200" + VERBOSE="" wget -q "${CLANG_LLVM_FULL_URL}" tar xf "${CLANG_LLVM_FILENAME}" @@ -82,10 +83,11 @@ case "${TYPE}" in echo "Checks: '-*'" >> _ci/.clang-tidy echo "WarningsAsErrors: ''" >> _ci/.clang-tidy else - POLLY_DISCARD_OPTIONS="" + VERBOSE=--verbose fi else - POLLY_DISCARD_OPTIONS="" + SHARED_SDK=ON + VERBOSE=--verbose fi if [[ ${TRAVIS} == "true" ]]; then @@ -105,15 +107,14 @@ case "${TYPE}" in polly.py \ --toolchain "${TOOLCHAIN}" \ --config "${CONFIG}" \ - --verbose \ - ${POLLY_DISCARD_OPTIONS} \ + ${VERBOSE} \ --ios-multiarch --ios-combined \ --archive drishti \ --jobs 4 \ ${TEST} \ "${INSTALL}" \ --fwd \ - DRISHTI_BUILD_SHARED_SDK=ON \ + DRISHTI_BUILD_SHARED_SDK=${SHARED_SDK} \ DRISHTI_BUILD_TESTS=YES \ DRISHTI_BUILD_EXAMPLES=YES \ DRISHTI_COPY_3RDPARTY_LICENSES=ON \ @@ -163,7 +164,7 @@ case "${TYPE}" in set -x - ./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH} + ../bin/travis_wait -i 60 "./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH}" exit 0 fi @@ -211,7 +212,7 @@ case "${TYPE}" in sleep 30 # Now should be fine - ./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH} + ../bin/travis_wait -i 60 "./gradlew assembleDebug -Parch=${ANDROID_STUDIO_ARCH}" # Back to normal CMake configuration sed -i 's,^if(DRISHTI_DEBUG_STOP OR TRUE)$,if(DRISHTI_DEBUG_STOP),' ../CMakeLists.txt diff --git a/src/app/dlib/eyexml.cpp b/src/app/dlib/eyexml.cpp index b20391b0..80e1104e 100644 --- a/src/app/dlib/eyexml.cpp +++ b/src/app/dlib/eyexml.cpp @@ -66,13 +66,13 @@ inline T ntoh_any(T t) { static const unsigned char int_bytes[sizeof(int)] = { 0xFF }; static const int msb_0xFF = 0xFF << (sizeof(int) - 1) * CHAR_BIT; - static bool host_is_big_endian = (*(reinterpret_cast(int_bytes)) & msb_0xFF) != 0; + static bool host_is_big_endian = (*(reinterpret_cast(int_bytes)) & msb_0xFF) != 0; // NOLINT (TODO) if (host_is_big_endian) { return t; } - auto* ptr = reinterpret_cast(&t); + auto* ptr = reinterpret_cast(&t); // NOLINT (TODO) std::reverse(ptr, ptr + sizeof(t)); return t; } @@ -85,9 +85,9 @@ static cv::Size read_png_size(const std::string& filename) { unsigned int width, height; in.seekg(16); - in.read(reinterpret_cast(&width), 4); - in.read(reinterpret_cast(&height), 4); - size = { static_cast(ntoh_any(width)), static_cast(ntoh_any(height)) }; + in.read(reinterpret_cast(&width), 4); // NOLINT (TODO) + in.read(reinterpret_cast(&height), 4); // NOLINT (TODO) + size = { static_cast(ntoh_any(width)), static_cast(ntoh_any(height)) }; // NOLINT (TODO) } return size; } @@ -137,8 +137,12 @@ class DlibDocument m_spec = drishti::eye::EyeModelSpecification::create(); } - ~DlibDocument() - = default; + DlibDocument(const DlibDocument&) = delete; + DlibDocument(DlibDocument&&) = delete; + DlibDocument& operator=(const DlibDocument&) = delete; + DlibDocument& operator=(DlibDocument&&) = delete; + + ~DlibDocument() = default; void start() { diff --git a/src/app/dlib/test_shape_predictor.cpp b/src/app/dlib/test_shape_predictor.cpp index 6ed96d19..9aeb720f 100644 --- a/src/app/dlib/test_shape_predictor.cpp +++ b/src/app/dlib/test_shape_predictor.cpp @@ -106,7 +106,7 @@ int mine(int argc, char* argv[]) drishti::ml::shape_predictor sp; load_cpb(sModel, sp); - int ellipse_count = sp.m_ellipse_count; + //int ellipse_count = sp.m_ellipse_count; #if 0 for(auto &f : filenames) diff --git a/src/app/eye/eye.cpp b/src/app/eye/eye.cpp index a89721c8..ef55362b 100644 --- a/src/app/eye/eye.cpp +++ b/src/app/eye/eye.cpp @@ -91,6 +91,11 @@ struct Padder : public Transform eye = eye - tl; } + Padder(const Padder&) = delete; + Padder(Padder&&) = delete; + Padder& operator=(const Padder&) = delete; + Padder& operator=(Padder&&) = delete; + static bool isGoodAspectRatio(const cv::Size& size, float targetAspectRatio) { const float currentAspectRatio = std::abs(static_cast(size.width) / static_cast(size.height)); @@ -124,6 +129,11 @@ struct Flopper : public Transform } } + Flopper(const Flopper&) = delete; + Flopper(Flopper&&) = delete; + Flopper& operator=(const Flopper&) = delete; + Flopper& operator=(Flopper&&) = delete; + bool isRight = true; }; @@ -151,6 +161,11 @@ struct Warper : public Transform } } + Warper(const Warper&) = delete; + Warper(Warper&&) = delete; + Warper& operator=(const Warper&) = delete; + Warper& operator=(Warper&&) = delete; + const cv::Matx33f* H = nullptr; }; diff --git a/src/app/facecrop/FaceJitterer.h b/src/app/facecrop/FaceJitterer.h index d983e689..23fe2b84 100644 --- a/src/app/facecrop/FaceJitterer.h +++ b/src/app/facecrop/FaceJitterer.h @@ -60,6 +60,13 @@ struct FaceWithLandmarks Landmarks eyesNoseMouth; // {eyeR, eyeL, nose, mouthR, mouthL} std::string filename; + FaceWithLandmarks() = default; + ~FaceWithLandmarks() = default; + + FaceWithLandmarks& operator=(FaceWithLandmarks&&) = default; + FaceWithLandmarks(FaceWithLandmarks&&) = default; + FaceWithLandmarks(const FaceWithLandmarks&) = default; + FaceWithLandmarks& operator=(const FaceWithLandmarks& src) { image = src.image; diff --git a/src/app/facecrop/facecrop.cpp b/src/app/facecrop/facecrop.cpp index 17f8c369..93337977 100644 --- a/src/app/facecrop/facecrop.cpp +++ b/src/app/facecrop/facecrop.cpp @@ -6,13 +6,13 @@ \copyright Copyright 2017 Elucideye, Inc. All rights reserved. \license{This project is released under the 3 Clause BSD License.} - + 1) POSITIVES --input= : filename + (optional) landmarks --format=(two|drishti|lfw|muct|helen|bioid|lfpw) --output= - 2) POSITIVES + NEGATIVES (non-overlapping negatives) + 2) POSITIVES + NEGATIVES (non-overlapping negatives) :: This would require adding object detection internally, it seems cleaner to leave hard negative :: sampling to another application. --input= : filename + (optional) landmarks @@ -24,7 +24,7 @@ --input= : filename + (optional) landmarks --format=raw --negatives= - + 4) NEGATIVES w/ INPAINTING --input= : filename + (optional) landmarks --format=raw @@ -112,7 +112,7 @@ struct GroundTruth } FACE::Table table; - GroundTruthFormat format; + GroundTruthFormat format = MUCTFormat; }; // ######################### SHA1 ##################################### @@ -255,32 +255,32 @@ int gauze_main(int argc, char* argv[]) ("0,zero", "Zero jitter model (photometric jitter only)", cxxopts::value(doPhotometricJitter)) ("l,landmarks", "Master landmark file (xml format)", cxxopts::value(sLandmarks)) ("m,mirror", "Perform jittering", cxxopts::value(doMirror)) - + #if defined(DRISHTI_BUILD_EOS) ("eos-model", "EOS 3D dephormable model", cxxopts::value(sEosModel)) ("eos-mapping", "EOS Landmark mapping", cxxopts::value(sEosMapping)) #endif ("standardize", "Standardize input files to filename + bounding boxes", cxxopts::value(sStandardize)) - + // ### Negative options ### ("I,inpaint", "Inpaint faces", cxxopts::value(doInpaint)) ("N,negatives","Negatives", cxxopts::value(sNegatives)) ("W,winsize", "Minimum window size", cxxopts::value(winSize)) ("B,background", "Background image list", cxxopts::value(sBackground)) - + // Output parameters: ("t,threads", "Thread count", cxxopts::value(threads)) ("h,help", "Print help message"); - // clang-format on - + // clang-format on + auto parseResult = options.parse(argc, argv); - + if((argumentCount <= 1) || parseResult.count("help")) { std::cout << options.help({""}) << std::endl; return 0; } - + // ############################################ // ### Command line argument error checking ### // ############################################ @@ -291,7 +291,7 @@ int gauze_main(int argc, char* argv[]) logger->error("Must specify output directory (positives or negatives)"); return 1; } - + // ... positives ... if(!sPositives.empty()) { @@ -306,7 +306,7 @@ int gauze_main(int argc, char* argv[]) return 1; } } - + if (!sLandmarks.empty()) { std::ofstream check(sLandmarks); @@ -320,7 +320,7 @@ int gauze_main(int argc, char* argv[]) return 1; } } - + // ... negatives ... if(!sNegatives.empty()) { @@ -335,7 +335,7 @@ int gauze_main(int argc, char* argv[]) return 1; } } - + // ### Input if(sInput.empty()) { @@ -347,7 +347,7 @@ int gauze_main(int argc, char* argv[]) logger->error("Specified input file does not exist or is not readable"); return 1; } - + //:::::::::::::::::::::::::: //::: Face jitter params ::: //:::::::::::::::::::::::::: @@ -362,7 +362,7 @@ int gauze_main(int argc, char* argv[]) ia(GENERIC_NVP("jitter", jitterParams)); } } // else we will be performing straight cropping or mirroring - + //::::::::::::::::::::::::::::::::: //::: Face normalization params ::: //::::::::::::::::::::::::::::::::: @@ -387,13 +387,13 @@ int gauze_main(int argc, char* argv[]) return -1; } } - + //::::::::::::::::::::::::::::::: //::: Parse input + landmarks ::: //::::::::::::::::::::::::::::::: GroundTruth gt = parseInput(sInput, sFormat, sDirectory, sExtension); auto &table = gt.table; - + if(table.lines.empty()) { logger->error("Error: no images were found, please check input file and (optionally) base directory"); @@ -408,7 +408,7 @@ int gauze_main(int argc, char* argv[]) return -1; } } - + if(!sStandardize.empty()) { return standardizeFaceData(table, sStandardize); @@ -421,7 +421,7 @@ int gauze_main(int argc, char* argv[]) return code; } } - + if(sPositives.empty() && !sNegatives.empty() && !doInpaint) { // ########################## @@ -437,14 +437,14 @@ int gauze_main(int argc, char* argv[]) // ################################### return saveInpaintedSamples(table, sBackground, sNegatives, *logger); } - + // ... ELSE STANDARD POSITIVES AND/OR NEGATIVES ... - + #if defined(DRISHTI_BUILD_EOS) if(!(sEosModel.empty() || sEosMapping.empty())) { computePose(table, sEosModel, sEosMapping, logger); - + { // Write name + angle: std::string filename; filename += sPositives; @@ -494,17 +494,17 @@ int gauze_main(int argc, char* argv[]) { // Get thread specific segmenter lazily: auto tid = std::this_thread::get_id(); - + auto &jitterer = manager[tid]; assert(jitterer.get()); - + // Load current image logger->info("{} = {}", table.lines[i].filename, repeat[i]); - + if(repeat[i] > 0) { cv::Mat image = cv::imread(table.lines[i].filename, cv::IMREAD_COLOR); - + if(!image.empty()) { @@ -526,34 +526,34 @@ int gauze_main(int argc, char* argv[]) faces.push_back((*jitterer)(image, table.lines[i].points, FaceJitterer::kJitter, doPhotometricJitter)); // no mirror } } - + if(!sPositives.empty()) { cv::Rect roi(cv::Point(faceSpec.border, faceSpec.border), faceSpec.size); save(faces, roi, sPositives, table.lines[i].filename, i); } - + jitterer->updateMean(faces); - + #if defined(DRISHTI_USE_IMSHOW) if(doPreview) { cv::Mat canvas = image.clone(); previewFaceWithLandmarks(canvas, table.lines[i].points); glfw::imshow("facecrop:image", canvas); - + std::vector images; for(const auto &f : faces) { cv::Mat chip = f.image.clone(); - previewFaceWithLandmarks(chip, f.landmarks); + previewFaceWithLandmarks(chip, f.landmarks); images.push_back(chip); } - + cv::hconcat(images, canvas); glfw::imshow("facecrop:jitter", canvas); glfw::imshow("facecrop::mu", jitterer->mu.image); - + glfw::waitKey(0); } #endif @@ -562,7 +562,7 @@ int gauze_main(int argc, char* argv[]) }; //harness({0,static_cast(table.lines.size())}); - + if(threads == 1 || threads == 0 || doPreview) { harness({0,static_cast(table.lines.size())}); @@ -571,9 +571,9 @@ int gauze_main(int argc, char* argv[]) { cv::parallel_for_({0,static_cast(table.lines.size())}, harness, std::max(threads, -1)); } - + saveMeanFace(manager, faceSpec, sPositives + "/mean.png", sPositives + "/mean", *logger); - + return 0; } @@ -595,7 +595,7 @@ int main(int argc, char **argv) { std::cerr << "Unknown exception catched" << std::endl; } - + exit(-1); } @@ -643,7 +643,7 @@ static GroundTruth parseInput(const std::string &sInput, const std::string &sFor default : CV_Assert(false); } - + std::string sDirectory = sDirectoryIn; if(!sDirectory.empty()) { @@ -651,7 +651,7 @@ static GroundTruth parseInput(const std::string &sInput, const std::string &sFor { sDirectory += "/"; } - + for(auto &l : gt.table.lines) { l.filename = sDirectory + l.filename; @@ -666,14 +666,14 @@ static GroundTruth parseInput(const std::string &sInput, const std::string &sFor { std::replace(begin(l.filename), end(l.filename), '\\', '/'); } - + return gt; } static FACE::Table parseRAW(const std::string &sInput) { const auto filenames = drishti::cli::expand(sInput); - + FACE::Table table; table.lines.resize(filenames.size()); for(int i = 0; i < filenames.size(); i++) @@ -708,7 +708,7 @@ static int standardizeFaceData(const FACE::Table &table, const std::string &sOut if(os) { auto landmarks = standardizeFaceData(table); - + cereal::JSONOutputArchive oa(os); using Archive = decltype(oa); oa(GENERIC_NVP("faces", landmarks)); @@ -735,13 +735,13 @@ static void computePose(FACE::Table &table, const std::string &sModel, const std { return drishti::core::make_unique(sModel, sMapping); }; - + drishti::core::ParallelHomogeneousLambda harness = [&](int i) { // Get thread specific segmenter lazily: auto tid = std::this_thread::get_id(); auto &meshMapper = manager[tid]; - + auto &record = table.lines[i]; if(record.points.size() == 68) { @@ -755,12 +755,12 @@ static void computePose(FACE::Table &table, const std::string &sModel, const std { size = cv::imread(record.filename).size(); } - + cv::Mat dummy; dummy.cols = size.width; dummy.rows = size.height; auto result = (*meshMapper)(record.points, dummy); - + const auto &q = result->getQuaternion(); record.quaternion = { q[0], q[1], q[2], q[3] }; // Note: q1 == frontal for now Eigen::Quaternion q0(q[0], q[1], q[2], q[3]), q1(0.f, 0.f, 0.f, 1.f), arc = q0 * q1.inverse(); @@ -771,10 +771,10 @@ static void computePose(FACE::Table &table, const std::string &sModel, const std #endif } }; - + cv::parallel_for_({0,static_cast(table.lines.size())}, harness, 8); } -#endif +#endif static int saveLandmarksJson(const std::string &sOutput, const std::vector &landmarks, spdlog::logger &logger) { @@ -822,7 +822,7 @@ static void saveMeanFace(FaceResourceManager &manager, const FaceSpecification & mu.image.convertTo(tmp, CV_8UC3, 255.0); cv::imwrite(sImage, tmp); } - + if(!sPoints.empty()) { // Output json for points @@ -834,7 +834,7 @@ static void saveMeanFace(FaceResourceManager &manager, const FaceSpecification & model.eyeRightCenter = mu.landmarks[0]; model.eyeLeftCenter = mu.landmarks[1]; model.noseTip = mu.landmarks[2]; - + cv::Matx33f T = transformation::translate(-tl); cv::Matx33f S = transformation::scale(faceSpec.size.width, faceSpec.size.height); model = (S.inv() * T) * model; // remove border and normalize @@ -898,7 +898,7 @@ static FaceWithLandmarks computeMeanFace(FaceResourceManager &manager) { count += j.second->mu.count; } - + FaceWithLandmarks mu; for(const auto &j : manager.getMap()) { @@ -915,7 +915,7 @@ static FaceWithLandmarks computeMeanFace(FaceResourceManager &manager) } } } - + return mu; } @@ -928,7 +928,7 @@ static void save_bbGtv3(const std::string &sOutput, const std::vector { static const char *sHeader = "% bbGt version=3"; static const char *sLabel = "face"; - + std::ofstream ofs(sOutput); if(ofs) { @@ -950,18 +950,33 @@ static void save(std::vector &faces, const cv::Rect &roi, con std::string base = drishti::core::basename(filename); { // save the image file - std::string sOutput = dir + "/" + ss.str() + "_" + base + ".png"; + std::string sOutput = dir; + sOutput += "/"; + sOutput += ss.str(); + sOutput += "_"; + sOutput += base; + sOutput += ".png"; cv::imwrite(sOutput, faces[i].image); faces[i].filename = sOutput; } - + { // Save bbox file for each face (compatible w/ Piotr's toolbox): - std::string sOutput = dir + "/" + ss.str() + "_" + base + ".txt"; + std::string sOutput = dir; + sOutput += "/"; + sOutput += ss.str(); + sOutput += "_"; + sOutput += base; + sOutput += ".txt"; save_bbGtv3(sOutput, {roi}); } { // Save the landmarks in a flat file: - std::string sOutput = dir + "/" + ss.str() + "_" + base + ".pts"; + std::string sOutput = dir; + sOutput += "/"; + sOutput += ss.str(); + sOutput += "_"; + sOutput += base; + sOutput += ".pts"; std::ofstream ofs(sOutput); if(ofs) { @@ -1000,39 +1015,44 @@ static int saveNegatives(const FACE::Table &table, const std::string &sOutput, i drishti::core::ParallelHomogeneousLambda harness = [&](int i) { cv::RNG rng; - + const auto &f = table.lines[i].filename; cv::Mat negative = cv::imread(f, cv::IMREAD_COLOR); - + int minDim = std::min(negative.cols, negative.rows); if((minDim >= winSize) && !negative.empty()) { + std::string filename; for(int j = 0; j < repeat[i]; j++) { const int width = rng.uniform(winSize, minDim); const int x = rng.uniform(0, negative.cols-width); const int y = rng.uniform(0, negative.rows-width); - + logger.info("roi:{},{},{},{}({})", x, y, width, width, winSize); cv::Mat crop = negative(cv::Rect(x, y, width, width)); - + cv::resize(crop, crop, {winSize, winSize}, 0, 0, cv::INTER_AREA); std::string sha1 = get_sha1(crop.ptr(), crop.total()); - cv::imwrite(sOutput + "/" + sha1 + ".png", crop); + filename = sOutput; + filename += "/"; + filename += sha1; + filename += ".png"; + cv::imwrite(filename, crop); } } }; - + //cv::parallel_for_({0,static_cast(sInput.size())}, harness, std::max(threads, -1)); harness({0,static_cast(repeat.size())}); - + return 0; } static int saveInpaintedSamples(const FACE::Table &table, const std::string& sBackground, const std::string &sOutput, spdlog::logger &logger) { cv::RNG rng; - + // Read a bunch of negative samples: std::vector negatives; auto filenames = drishti::cli::expand(sBackground); @@ -1044,13 +1064,13 @@ static int saveInpaintedSamples(const FACE::Table &table, const std::string& sBa negatives.push_back(I); } } - + std::map< std::string, std::vector*> > landmarks; for(const auto &r : table.lines) { landmarks[r.filename].push_back(&r.points); } - + drishti::core::ParallelHomogeneousLambda harness = [&](int i) { const auto &r = table.lines[i]; @@ -1058,7 +1078,7 @@ static int saveInpaintedSamples(const FACE::Table &table, const std::string& sBa if(!image.empty()) { logger.info("faceless:{}", r.filename); - + cv::Mat blended; auto iter = landmarks.find(r.filename); if(iter != landmarks.end()) @@ -1070,15 +1090,15 @@ static int saveInpaintedSamples(const FACE::Table &table, const std::string& sBa const cv::RotatedRect face(center, cv::Size2f(roi.width, roi.height*2.f), 0); cv::Mat mask(image.size(), CV_8UC3, cv::Scalar::all(0)); cv::ellipse(mask, face, cv::Scalar::all(255), -1, 8); - + cv::Mat bg; cv::resize(negatives[rng.uniform(0, negatives.size())], bg, image.size(), 0, 0, cv::INTER_AREA); - + blended = blend(blended.empty() ? image : blended, bg, mask, 6); blended.convertTo(blended, CV_8UC3, 255.0); } } - + if(!blended.empty()) { std::string base = drishti::core::basename(r.filename); @@ -1086,9 +1106,9 @@ static int saveInpaintedSamples(const FACE::Table &table, const std::string& sBa } } }; - + //cv::parallel_for_({0,static_cast(table.lines.size()}, harness, std::max(threads, -1)); harness({0,static_cast(table.lines.size())}); - + return 0; } diff --git a/src/app/fddb/FDDB.h b/src/app/fddb/FDDB.h index 9703cfa0..50e1b2a9 100644 --- a/src/app/fddb/FDDB.h +++ b/src/app/fddb/FDDB.h @@ -30,7 +30,7 @@ namespace FDDB struct record { using Ellipse = std::vector; - typedef std::pair EllipseEntry; + using EllipseEntry = std::pair; std::string filename; std::vector ellipses; diff --git a/src/app/fddb/fddbcrop.cpp b/src/app/fddb/fddbcrop.cpp index c9a898ef..13ded01f 100644 --- a/src/app/fddb/fddbcrop.cpp +++ b/src/app/fddb/fddbcrop.cpp @@ -43,9 +43,9 @@ int main(int argc, char* argv[]) ("o,output", "Output directory", cxxopts::value(sOutput)) ("t,text", "Text directory", cxxopts::value(sTextDir)) ("f,face", "Face directory", cxxopts::value(sFaceDir)) - ("v,verbose", "Verbose output", cxxopts::value(doVerbose)) + ("v,verbose", "Verbose output", cxxopts::value(doVerbose)) ("h,help", "Print help message"); - // clang-format on + // clang-format on auto parseResult = options.parse(argc, argv); @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) { std::cout << options.help({""}) << std::endl; return 0; - } + } // The master input list looks like this: // @@ -67,68 +67,68 @@ int main(int argc, char* argv[]) // 54.885 35.9912 1.49674 137.485 156.363 1 // 58.1053 41.7296 1.32333 304.696 157.209 1 // 54.3857 41.4509 -1.51792 439.195 56.9354 1 - + // We want to dump each image entry to its own file: // 2002/08/07/big/img_1358 => 2002_08_07_big_img_1358 std::vector records = parseFDDB(sInput); - + for(auto &r : records) { bfs::path imageFilename, textFilename; std::string flatFilename; - + { bfs::path file(r.filename); textFilename = (bfs::path(sTextDir) / file).replace_extension(".txt"); imageFilename = (bfs::path(sFaceDir) / file).replace_extension(".jpg"); - + flatFilename = r.filename; std::replace(flatFilename.begin(), flatFilename.end(), '/', '_'); std::cout << r.filename << " = " << flatFilename << std::endl; } - + // lbl - a string label describing object type (eg: 'pedestrian') // bb - [l t w h]: bb indicating predicted object extent // occ - 0/1 value indicating if bb is occluded // bbv - [l t w h]: bb indicating visible region (may be [0 0 0 0]) // ign - 0/1 value indicating bb was marked as ignore // ang - [0-360] orientation of bb in degrees - + drishti::ml::BoundingBoxSet objectSet; - + for(auto &l : r.ellipses) { const auto &e = l.first; cv::RotatedRect ellipse( cv::Point2d(e[3],e[4]), cv::Size2d(e[0]*2.0,e[1]*2.0), e[2]*180.0/M_PI ); - + float r = ((ellipse.size.width + ellipse.size.height) * 0.25f) * 0.75f; cv::Point2f v(std::cos(e[2]), std::sin(e[2])), c = ellipse.center + (v * ((0 parser; - bool success = qi::phrase_parse(begin, end, parser, qi::blank, output); + bool success = qi::phrase_parse(begin, end, parser, qi::blank, output); // NOLINT (TODO) } } diff --git a/src/app/landmarks/DlibXML.h b/src/app/landmarks/DlibXML.h index 503057eb..c4ee0872 100644 --- a/src/app/landmarks/DlibXML.h +++ b/src/app/landmarks/DlibXML.h @@ -53,13 +53,13 @@ inline T ntoh_any(T t) { static const unsigned char int_bytes[sizeof(int)] = { 0xFF }; static const int msb_0xFF = 0xFF << (sizeof(int) - 1) * CHAR_BIT; - static bool host_is_big_endian = (*(reinterpret_cast(int_bytes)) & msb_0xFF) != 0; + static bool host_is_big_endian = (*(reinterpret_cast(int_bytes)) & msb_0xFF) != 0; // NOLINT (TODO) if (host_is_big_endian) { return t; } - auto* ptr = reinterpret_cast(&t); + auto* ptr = reinterpret_cast(&t); // NOLINT (TODO) std::reverse(ptr, ptr + sizeof(t)); return t; } @@ -72,8 +72,8 @@ inline cv::Size read_png_size(const std::string& filename) { unsigned int width, height; in.seekg(16); - in.read(reinterpret_cast(&width), 4); - in.read(reinterpret_cast(&height), 4); + in.read(reinterpret_cast(&width), 4); // NOLINT (TODO) + in.read(reinterpret_cast(&height), 4); // NOLINT (TODO) size = { static_cast(ntoh_any(width)), static_cast(ntoh_any(height)) }; } return size; @@ -102,6 +102,11 @@ class DlibDocument DlibDocument() = default; ~DlibDocument() = default; + DlibDocument(const DlibDocument&) = delete; + DlibDocument(DlibDocument&&) = delete; + DlibDocument& operator=(const DlibDocument&) = delete; + DlibDocument& operator=(DlibDocument&&) = delete; + void start() { static const char* sStyleSheet = "xml-stylesheet type='text/xsl' href='image_metadata_stylesheet.xsl'"; diff --git a/src/app/landmarks/HELEN.cpp b/src/app/landmarks/HELEN.cpp index 7d3b45e6..bdfe8518 100644 --- a/src/app/landmarks/HELEN.cpp +++ b/src/app/landmarks/HELEN.cpp @@ -128,7 +128,7 @@ FACE::Table parseHELEN(const std::string& filename) is.unsetf(std::ios::skipws); boost::spirit::istream_iterator begin(is), end; FACE::helen_parser parser; - bool success = qi::phrase_parse(begin, end, parser, qi::blank, output); + bool success = qi::phrase_parse(begin, end, parser, qi::blank, output); // NOLINT (TODO) table.lines.resize(output.lines.size()); for (int i = 0; i < table.lines.size(); i++) diff --git a/src/app/landmarks/LFW.cpp b/src/app/landmarks/LFW.cpp index a63c8134..dec391db 100644 --- a/src/app/landmarks/LFW.cpp +++ b/src/app/landmarks/LFW.cpp @@ -110,7 +110,7 @@ FACE::Table parseLFW(const std::string& filename) LFW::lfw_parser parser; LFW::Table result; - bool success = qi::phrase_parse(begin, end, parser, qi::blank, result); + bool success = qi::phrase_parse(begin, end, parser, qi::blank, result); // NOLINT (TODO) table.lines.resize(result.lines.size()); for (int i = 0; i < result.lines.size(); i++) diff --git a/src/app/landmarks/MUCT.cpp b/src/app/landmarks/MUCT.cpp index 6f46d21a..0a82f4a2 100644 --- a/src/app/landmarks/MUCT.cpp +++ b/src/app/landmarks/MUCT.cpp @@ -75,7 +75,7 @@ FACE::Table parseMUCT(const std::string& filename) is.unsetf(std::ios::skipws); boost::spirit::istream_iterator begin(is), end; FACE::muct_parser parser; - bool success = qi::phrase_parse(begin, end, parser, qi::blank, table); + bool success = qi::phrase_parse(begin, end, parser, qi::blank, table); // NOLINT (TODO) } return table; } diff --git a/src/app/landmarks/TWO.cpp b/src/app/landmarks/TWO.cpp index c4196139..58b31203 100644 --- a/src/app/landmarks/TWO.cpp +++ b/src/app/landmarks/TWO.cpp @@ -108,7 +108,7 @@ FACE::Table parseTWO(const std::string& filename) TWO::two_parser parser; TWO::Table result; - bool success = qi::phrase_parse(f, l, parser, qi::blank, result); + bool success = qi::phrase_parse(f, l, parser, qi::blank, result); // NOLINT (TODO) table.lines.resize(result.lines.size()); for (int i = 0; i < result.lines.size(); i++) diff --git a/src/app/videoio/VideoSinkCV.h b/src/app/videoio/VideoSinkCV.h index 9538b9f9..d3f8e414 100644 --- a/src/app/videoio/VideoSinkCV.h +++ b/src/app/videoio/VideoSinkCV.h @@ -34,6 +34,12 @@ class VideoSinkCV VideoSinkCV() = default; ~VideoSinkCV() = default; + + VideoSinkCV(const VideoSinkCV&) = delete; + VideoSinkCV(VideoSinkCV&&) = delete; + VideoSinkCV& operator=(const VideoSinkCV&) = delete; + VideoSinkCV& operator=(VideoSinkCV&&) = delete; + virtual bool good() = 0; virtual bool begin() = 0; virtual bool operator()(const cv::Mat& image) = 0; diff --git a/src/app/videoio/VideoSourceCV.cpp b/src/app/videoio/VideoSourceCV.cpp index 30158e8c..c4663d5e 100644 --- a/src/app/videoio/VideoSourceCV.cpp +++ b/src/app/videoio/VideoSourceCV.cpp @@ -61,6 +61,12 @@ class VideoSourceOpenCV : public VideoSourceCV } } ~VideoSourceOpenCV() = default; + + VideoSourceOpenCV(const VideoSourceOpenCV&) = delete; + VideoSourceOpenCV(VideoSourceOpenCV&&) = delete; + VideoSourceOpenCV& operator=(const VideoSourceOpenCV&) = delete; + VideoSourceOpenCV& operator=(VideoSourceOpenCV&&) = delete; + Frame operator()(int i) override { cv::Mat frame; diff --git a/src/app/videoio/VideoSourceCV.h b/src/app/videoio/VideoSourceCV.h index d6925a95..6a938201 100644 --- a/src/app/videoio/VideoSourceCV.h +++ b/src/app/videoio/VideoSourceCV.h @@ -65,6 +65,11 @@ class VideoSourceCV VideoSourceCV() = default; ~VideoSourceCV() = default; + VideoSourceCV(const VideoSourceCV&) = delete; + VideoSourceCV(VideoSourceCV&&) = delete; + VideoSourceCV& operator=(const VideoSourceCV&) = delete; + VideoSourceCV& operator=(VideoSourceCV&&) = delete; + virtual Frame operator()(int i = -1) = 0; virtual bool good() const { return true; } virtual std::size_t count() const = 0; diff --git a/src/app/videoio/VideoSourceStills.cpp b/src/app/videoio/VideoSourceStills.cpp index 34ceba19..4c7f4c69 100644 --- a/src/app/videoio/VideoSourceStills.cpp +++ b/src/app/videoio/VideoSourceStills.cpp @@ -2,10 +2,10 @@ @file videoio/VideoSourceStills.cpp @author David Hirvonen @brief Simple implementation of a list-of-files VideoSource. - + \copyright Copyright 2017 Elucideye, Inc. All rights reserved. \license{This project is released under the 3 Clause BSD License.} - + */ #include "videoio/VideoSourceStills.h" @@ -23,19 +23,24 @@ DRISHTI_VIDEOIO_NAMESPACE_BEGIN class VideoSourceStills::Impl { public: - Impl(std::string filename) + explicit Impl(std::string filename) : m_filename(std::move(filename)) { m_filenames = drishti::cli::expand(m_filename); } - Impl(std::vector filenames) + explicit Impl(std::vector filenames) : m_filenames(std::move(filenames)) { } ~Impl() = default; + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + std::size_t count() const { return m_filenames.size(); @@ -43,10 +48,10 @@ class VideoSourceStills::Impl VideoSourceCV::Frame operator()(int i = -1) { - if (!((0 <= i) && (i < m_filenames.size()))) - { - return {}; - } + if (!((0 <= i) && (i < m_filenames.size()))) + { + return {}; + } return VideoSourceCV::Frame(cv::imread(m_filenames[i]), i, m_filenames[i]); } diff --git a/src/app/videoio/VideoSourceStills.h b/src/app/videoio/VideoSourceStills.h index 533fc32b..af52775e 100644 --- a/src/app/videoio/VideoSourceStills.h +++ b/src/app/videoio/VideoSourceStills.h @@ -25,9 +25,15 @@ class VideoSourceStills : public VideoSourceCV public: class Impl; - VideoSourceStills(const std::string& filename); - VideoSourceStills(const std::vector& filenames); + explicit VideoSourceStills(const std::string& filename); + explicit VideoSourceStills(const std::vector& filenames); ~VideoSourceStills(); + + VideoSourceStills(const VideoSourceStills&) = delete; + VideoSourceStills(VideoSourceStills&&) = delete; + VideoSourceStills& operator=(const VideoSourceStills&) = delete; + VideoSourceStills& operator=(VideoSourceStills&&) = delete; + Frame operator()(int i = -1) override; std::size_t count() const override; bool isRandomAccess() const override { return true; } diff --git a/src/app/videoio/VideoSourceTest.cpp b/src/app/videoio/VideoSourceTest.cpp index dbea210e..19edd8ab 100644 --- a/src/app/videoio/VideoSourceTest.cpp +++ b/src/app/videoio/VideoSourceTest.cpp @@ -36,7 +36,7 @@ auto VideoSourceTest::operator()(int i) -> Frame } Frame frame; - frame.image = cv::Mat(480, 640, type, cv::Scalar(rand() % 255, rand() % 255, rand() % 255, 255)); + frame.image = cv::Mat(480, 640, type, cv::Scalar(rand() % 255, rand() % 255, rand() % 255, 255)); // NOLINT (TODO) frame.index = counter++; frame.name = std::to_string(frame.index); return frame; diff --git a/src/examples/facefilter/lib/facefilter/renderer/Context.cpp b/src/examples/facefilter/lib/facefilter/renderer/Context.cpp index 32807876..73004493 100644 --- a/src/examples/facefilter/lib/facefilter/renderer/Context.cpp +++ b/src/examples/facefilter/lib/facefilter/renderer/Context.cpp @@ -27,13 +27,8 @@ BEGIN_FACEFILTER_NAMESPACE static std::shared_ptr createLogger(const char* name); Application::Application() - : m_hasCamera(false) - , m_hasDisplay(false) -#if defined(__ANDROID__) - , m_JNIEnv(nullptr) -#endif { - m_logger = createLogger("facefilter"); + m_logger = createLogger("facefilter"); // NOLINT (TODO) } Application::~Application() diff --git a/src/examples/facefilter/lib/facefilter/renderer/Context.h b/src/examples/facefilter/lib/facefilter/renderer/Context.h index 75508108..563b3e40 100644 --- a/src/examples/facefilter/lib/facefilter/renderer/Context.h +++ b/src/examples/facefilter/lib/facefilter/renderer/Context.h @@ -37,6 +37,12 @@ struct Application public: Application(); ~Application(); + + Application(const Application&) = delete; + Application(Application&&) = delete; + Application& operator=(const Application&) = delete; + Application& operator=(Application&&) = delete; + void setAssetManager(void* assetManager); void loadAsset(const char* key, const char* filename); void drawFrame(std::uint32_t texId); @@ -62,20 +68,20 @@ struct Application void* m_context = nullptr; std::function setDisplayBufferCallback; - bool m_hasCamera; - int m_cameraWidth; - int m_cameraHeight; - int m_cameraRotation; - float m_cameraFocalLength; + bool m_hasCamera{false}; + int m_cameraWidth{}; + int m_cameraHeight{}; + int m_cameraRotation{}; + float m_cameraFocalLength{}; - bool m_hasDisplay; - int m_displayWidth; - int m_displayHeight; + bool m_hasDisplay{false}; + int m_displayWidth{}; + int m_displayHeight{}; std::string m_assets; #if defined(__ANDROID__) - JNIEnv* m_JNIEnv; + JNIEnv* m_JNIEnv{nullptr}; jobject m_jobject; #endif diff --git a/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerFactoryJson.cpp b/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerFactoryJson.cpp index d3efdb67..3e093f41 100644 --- a/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerFactoryJson.cpp +++ b/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerFactoryJson.cpp @@ -48,7 +48,7 @@ FaceTrackerFactoryJson::FaceTrackerFactoryJson(const std::string& sModels, std:: void FaceTrackerFactoryJson::init(const std::string& sModels, std::shared_ptr& logger) { - auto ifs = open_stream(sModels); + auto ifs = open_stream(sModels); // NOLINT (TODO) nlohmann::json json = nlohmann::json::parse(*ifs); diff --git a/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.cpp b/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.cpp index 623ec18b..86c9cfaa 100644 --- a/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.cpp +++ b/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.cpp @@ -19,6 +19,11 @@ struct FaceTrackTest::Impl // CUSTOM user constructor } + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + ~Impl() = default; // CUSTOM user fields @@ -72,7 +77,7 @@ int FaceTrackTest::allocator(const drishti_image_t& spec, drishti::sdk::Image4b& int FaceTrackTest::callbackFunc(void* context, drishti_face_tracker_results_t& results) { - if (FaceTrackTest* ft = static_cast(context)) + if (auto* ft = static_cast(context)) { return ft->callback(results); } @@ -82,7 +87,7 @@ int FaceTrackTest::callbackFunc(void* context, drishti_face_tracker_results_t& r drishti_request_t FaceTrackTest::triggerFunc(void* context, const drishti_face_tracker_result_t& faces, double timestamp, std::uint32_t tex) { - if (FaceTrackTest* ft = static_cast(context)) + if (auto* ft = static_cast(context)) { return ft->trigger(faces, timestamp, tex); } @@ -91,7 +96,7 @@ FaceTrackTest::triggerFunc(void* context, const drishti_face_tracker_result_t& f int FaceTrackTest::allocatorFunc(void* context, const drishti_image_t& spec, drishti::sdk::Image4b& image) { - if (FaceTrackTest* ft = static_cast(context)) + if (auto* ft = static_cast(context)) { return ft->allocator(spec, image); } diff --git a/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.h b/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.h index a58f6983..bba018a8 100644 --- a/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.h +++ b/src/examples/facefilter/lib/facefilter/renderer/FaceTrackerTest.h @@ -34,6 +34,11 @@ class FaceTrackTest FaceTrackTest(std::shared_ptr& logger, const std::string& sOutput); ~FaceTrackTest(); + FaceTrackTest(const FaceTrackTest&) = delete; + FaceTrackTest(FaceTrackTest&&) = delete; + FaceTrackTest& operator=(const FaceTrackTest&) = delete; + FaceTrackTest& operator=(FaceTrackTest&&) = delete; + // Callback definitions: { int allocator(const drishti_image_t& spec, drishti::sdk::Image4b& image); static int allocatorFunc(void* context, const drishti_image_t& spec, drishti::sdk::Image4b& image); diff --git a/src/examples/facefilter/lib/facefilter/renderer/Renderer.h b/src/examples/facefilter/lib/facefilter/renderer/Renderer.h index f48f6c81..934e80d6 100644 --- a/src/examples/facefilter/lib/facefilter/renderer/Renderer.h +++ b/src/examples/facefilter/lib/facefilter/renderer/Renderer.h @@ -33,6 +33,12 @@ class Renderer const cv::Size& displaySize, Application& application); virtual ~Renderer(); + + Renderer(const Renderer&) = delete; + Renderer(Renderer&&) = delete; + Renderer& operator=(const Renderer&) = delete; + Renderer& operator=(Renderer&&) = delete; + void resize(int w, int h); void setPreviewGeometry(float tx, float ty, float sx, float sy); void render(); diff --git a/src/lib/drishti/core/Field.h b/src/lib/drishti/core/Field.h index fb28c497..3f818cca 100644 --- a/src/lib/drishti/core/Field.h +++ b/src/lib/drishti/core/Field.h @@ -5,7 +5,7 @@ \copyright Copyright 2014-2016 Elucideye, Inc. All rights reserved. \license{This project is released under the 3 Clause BSD License.} - + NOTE: GENERIC_NVP should be defined prior to including this class for either boost or cereal archives. @@ -24,9 +24,7 @@ DRISHTI_CORE_NAMESPACE_BEGIN template struct Field { - Field() - - = default; + Field() = default; Field(const T& t) : has(true) , value(t) @@ -34,6 +32,12 @@ struct Field } ~Field() = default; + // TODO (?) + Field(const Field&) = default; + Field(Field&&) = default; // NOLINT (TODO) + Field& operator=(const Field&) = default; + Field& operator=(Field&&) = default; // NOLINT (TODO) + Field& operator=(const T& src) { has = true; diff --git a/src/lib/drishti/core/LazyParallelResource.h b/src/lib/drishti/core/LazyParallelResource.h index dabdd74d..7cd8d82e 100644 --- a/src/lib/drishti/core/LazyParallelResource.h +++ b/src/lib/drishti/core/LazyParallelResource.h @@ -27,12 +27,18 @@ struct LazyParallelResource : m_alloc(std::forward(func)) { } - LazyParallelResource(LazyParallelResource&& other) + LazyParallelResource(LazyParallelResource&& other) noexcept : m_alloc(std::move(other.m_alloc)) { other.m_alloc = nullptr; } + LazyParallelResource(const LazyParallelResource&) = default; + LazyParallelResource& operator=(const LazyParallelResource&) = default; + LazyParallelResource& operator=(LazyParallelResource&&) = default; // NOLINT (TODO) + + ~LazyParallelResource() = default; + virtual Value& operator[](const Key& key) { std::unique_lock lock(m_mutex); diff --git a/src/lib/drishti/core/Logger.cpp b/src/lib/drishti/core/Logger.cpp index 5f96568c..f44cd335 100644 --- a/src/lib/drishti/core/Logger.cpp +++ b/src/lib/drishti/core/Logger.cpp @@ -42,7 +42,7 @@ std::shared_ptr Logger::create(const char* name) { // Check for existing logger auto logger = get(name); - if (logger) + if (logger) // NOLINT (TODO) { return logger; } @@ -55,7 +55,7 @@ std::shared_ptr Logger::create(const char* name) #endif auto logger = std::make_shared(name, begin(sinks), end(sinks)); spdlog::register_logger(logger); - spdlog::set_pattern("[%H:%M:%S.%e | thread:%t | %n | %l]: %v"); + spdlog::set_pattern("[%H:%M:%S.%e | thread:%t | %n | %l]: %v"); // NOLINT (TODO) return logger; } diff --git a/src/lib/drishti/core/Parallel.h b/src/lib/drishti/core/Parallel.h index 5e404681..a89300ab 100644 --- a/src/lib/drishti/core/Parallel.h +++ b/src/lib/drishti/core/Parallel.h @@ -32,8 +32,12 @@ struct ParallelHeterogeneousLambda : public cv::ParallelLoopBody } } + ~ParallelHeterogeneousLambda() override = default; + ParallelHeterogeneousLambda(const ParallelHeterogeneousLambda&) = delete; - void operator=(const ParallelHeterogeneousLambda&) = delete; + ParallelHeterogeneousLambda(ParallelHeterogeneousLambda&&) = delete; + ParallelHeterogeneousLambda& operator=(const ParallelHeterogeneousLambda&) = delete; + ParallelHeterogeneousLambda& operator=(ParallelHeterogeneousLambda&&) = delete; protected: std::vector> m_functions; @@ -53,7 +57,7 @@ struct ParallelHomogeneousLambda : public cv::ParallelLoopBody { } - ParallelHomogeneousLambda(ParallelHomogeneousLambda&& other) + ParallelHomogeneousLambda(ParallelHomogeneousLambda&& other) noexcept : m_function(std::move(other.m_function)) { other.m_function = nullptr; @@ -68,7 +72,10 @@ struct ParallelHomogeneousLambda : public cv::ParallelLoopBody } ParallelHomogeneousLambda(const ParallelHomogeneousLambda&) = delete; - void operator=(const ParallelHomogeneousLambda&) = delete; + ParallelHomogeneousLambda operator=(const ParallelHomogeneousLambda&) = delete; + ParallelHomogeneousLambda operator=(ParallelHomogeneousLambda&&) = delete; + + ~ParallelHomogeneousLambda() override = default; protected: std::function m_function; @@ -88,7 +95,7 @@ struct ParallelLambdaRange : public cv::ParallelLoopBody { } - ParallelLambdaRange(ParallelLambdaRange&& other) + ParallelLambdaRange(ParallelLambdaRange&& other) noexcept : m_function(std::move(other.m_function)) { other.m_function = nullptr; @@ -100,7 +107,10 @@ struct ParallelLambdaRange : public cv::ParallelLoopBody } ParallelLambdaRange(const ParallelLambdaRange&) = delete; - void operator=(const ParallelLambdaRange&) = delete; + ParallelLambdaRange& operator=(const ParallelLambdaRange&) = delete; + ParallelLambdaRange& operator=(ParallelLambdaRange&&) = delete; + + ~ParallelLambdaRange() override = default; protected: std::function m_function; diff --git a/src/lib/drishti/core/Shape.cpp b/src/lib/drishti/core/Shape.cpp index e986e614..51894ac8 100644 --- a/src/lib/drishti/core/Shape.cpp +++ b/src/lib/drishti/core/Shape.cpp @@ -166,7 +166,7 @@ void upsample(const PointVec& controlPoints, PointVec& interpolatedPoints, int f { if (controlPoints.size() > 1) { - typedef Eigen::Spline Spline2d; + using Spline2d = Eigen::Spline; using PointType = Spline2d::PointType; using ControlPointVectorType = Spline2d::ControlPointVectorType; diff --git a/src/lib/drishti/core/ThreadPool.h b/src/lib/drishti/core/ThreadPool.h index db9e473e..430b6332 100644 --- a/src/lib/drishti/core/ThreadPool.h +++ b/src/lib/drishti/core/ThreadPool.h @@ -24,10 +24,13 @@ class ThreadPoolSource private: ThreadPoolSource() = default; + ~ThreadPoolSource() = default; public: ThreadPoolSource(ThreadPoolSource const&) = delete; - void operator=(ThreadPoolSource const&) = delete; + ThreadPoolSource(ThreadPoolSource&&) = delete; + ThreadPoolSource& operator=(const ThreadPoolSource&) = delete; + ThreadPoolSource& operator=(ThreadPoolSource&&) = delete; }; DRISHTI_CORE_NAMESPACE_END diff --git a/src/lib/drishti/core/ThrowAssert.h b/src/lib/drishti/core/ThrowAssert.h index efee8e25..ce0a97bb 100644 --- a/src/lib/drishti/core/ThrowAssert.h +++ b/src/lib/drishti/core/ThrowAssert.h @@ -138,8 +138,12 @@ class AssertionFailureException : public std::exception return message.c_str(); } - ~AssertionFailureException() noexcept override - = default; + AssertionFailureException(const AssertionFailureException&) = delete; + AssertionFailureException(AssertionFailureException&&) = default; + AssertionFailureException& operator=(const AssertionFailureException&) = delete; + AssertionFailureException& operator=(AssertionFailureException&&) = delete; + + ~AssertionFailureException() noexcept override = default; }; DRISHTI_CORE_NAMESPACE_END diff --git a/src/lib/drishti/core/arithmetic.cpp b/src/lib/drishti/core/arithmetic.cpp index eb03d819..066690d2 100644 --- a/src/lib/drishti/core/arithmetic.cpp +++ b/src/lib/drishti/core/arithmetic.cpp @@ -9,6 +9,8 @@ */ #include "drishti/core/arithmetic.h" + +#include #include "drishti/core/drishti_math.h" // clang-format off @@ -23,7 +25,7 @@ DRISHTI_CORE_NAMESPACE_BEGIN template <> float round(float x) { - return ::round(x); + return std::round(x); } template <> double round(double x) diff --git a/src/lib/drishti/core/hungarian.cpp b/src/lib/drishti/core/hungarian.cpp index 35c3ca42..ed15757e 100644 --- a/src/lib/drishti/core/hungarian.cpp +++ b/src/lib/drishti/core/hungarian.cpp @@ -58,11 +58,11 @@ class HungarianOptimizer private: using Step = void (drishti::core::HungarianOptimizer::*)(); - typedef enum { + enum Mark { NONE, PRIME, STAR - } Mark; + }; // Convert the final cost matrix into a set of assignments of agents -> tasks. // Returns the assignment in the two vectors passed as argument, the same as diff --git a/src/lib/drishti/core/infix_iterator.h b/src/lib/drishti/core/infix_iterator.h index 002aed4d..dafd6380 100644 --- a/src/lib/drishti/core/infix_iterator.h +++ b/src/lib/drishti/core/infix_iterator.h @@ -30,7 +30,7 @@ class infix_ostream_iterator : public std::iterator ostream_type; + using ostream_type = std::basic_ostream; infix_ostream_iterator(ostream_type& s) : os(&s) , delimiter(0) diff --git a/src/lib/drishti/core/scope_guard.h b/src/lib/drishti/core/scope_guard.h index 37cd7faa..f69c22f1 100644 --- a/src/lib/drishti/core/scope_guard.h +++ b/src/lib/drishti/core/scope_guard.h @@ -25,7 +25,7 @@ class scope_guard { } - scope_guard(scope_guard&& other) + scope_guard(scope_guard&& other) noexcept : f(std::move(other.f)) { other.f = nullptr; @@ -43,7 +43,8 @@ class scope_guard } scope_guard(const scope_guard&) = delete; - void operator=(const scope_guard&) = delete; + scope_guard& operator=(const scope_guard&) = delete; + scope_guard& operator=(scope_guard&&) = delete; private: std::function f; diff --git a/src/lib/drishti/core/timing.h b/src/lib/drishti/core/timing.h index 1fa7a9f3..6f919c1b 100644 --- a/src/lib/drishti/core/timing.h +++ b/src/lib/drishti/core/timing.h @@ -31,7 +31,7 @@ class ScopeTimeLogger m_tic = HighResolutionClock::now(); } - ScopeTimeLogger(ScopeTimeLogger&& other) + ScopeTimeLogger(ScopeTimeLogger&& other) noexcept : m_logger(std::move(other.m_logger)) , m_tic(other.m_tic) { @@ -44,7 +44,8 @@ class ScopeTimeLogger } ScopeTimeLogger(const ScopeTimeLogger&) = delete; - void operator=(const ScopeTimeLogger&) = delete; + ScopeTimeLogger& operator=(const ScopeTimeLogger&) = delete; + ScopeTimeLogger& operator=(ScopeTimeLogger&&) = delete; static double timeDifference(const TimePoint& a, const TimePoint& b) { diff --git a/src/lib/drishti/core/ut/test-drishti-core.cpp b/src/lib/drishti/core/ut/test-drishti-core.cpp index d990999c..57f3f757 100644 --- a/src/lib/drishti/core/ut/test-drishti-core.cpp +++ b/src/lib/drishti/core/ut/test-drishti-core.cpp @@ -20,7 +20,7 @@ BEGIN_EMPTY_NAMESPACE -TEST(HungarianAssignment, hungarian) +TEST(HungarianAssignment, hungarian) // NOLINT (TODO) { std::vector points1{ { 1.f, 1.f }, diff --git a/src/lib/drishti/drishti/Array.hpp b/src/lib/drishti/drishti/Array.hpp index 1e7fa283..9e7dafd8 100644 --- a/src/lib/drishti/drishti/Array.hpp +++ b/src/lib/drishti/drishti/Array.hpp @@ -24,7 +24,7 @@ class Array { public: // http://stackoverflow.com/a/7759622 - class iterator + class iterator // NOLINT (TODO) { public: using difference_type = typename std::ptrdiff_t; @@ -33,13 +33,13 @@ class Array using pointer = T*; using iterator_category = std::forward_iterator_tag; using size_type = std::size_t; - + iterator() = default; iterator(const iterator& other) : ptr_(other.ptr_) { } - iterator(pointer ptr_) + explicit iterator(pointer ptr_) : ptr_(ptr_) { } @@ -100,20 +100,23 @@ class Array using size_type = std::size_t; const_iterator() = default; - const_iterator(const const_iterator& other) + explicit const_iterator(const const_iterator& other) : ptr_(other.ptr_) { } - const_iterator(const iterator& other) + explicit const_iterator(const iterator& other) : ptr_(other.ptr_) { } - const_iterator(const_pointer ptr_) + explicit const_iterator(const_pointer ptr_) : ptr_(ptr_) { } ~const_iterator() = default; + const_iterator(const_iterator&&) noexcept = default; + const_iterator& operator=(const_iterator&&) = delete; + const_iterator& operator=(const const_iterator& other) { ptr_ = other.ptr_; @@ -158,10 +161,9 @@ class Array const_pointer ptr_; }; - Array() - - = default; - Array(std::size_t size) + Array() = default; + ~Array() = default; + explicit Array(std::size_t size) : size_(std::min(size, N)) { } // clippinpg semantics @@ -174,6 +176,10 @@ class Array } } + Array(Array&&) noexcept = default; + Array& operator=(const Array&) = default; + Array& operator=(Array&&) noexcept = default; + void clear() { size_ = 0; } void resize(std::size_t size) { size_ = std::min(N, size); } @@ -184,11 +190,11 @@ class Array T& operator[](std::size_t index) { return data_[index]; } const T& operator[](std::size_t index) const { return data_[index]; } - iterator begin() { return data_; } - iterator end() { return (data_ + size_); } + iterator begin() { return iterator(data_); } + iterator end() { return iterator(data_ + size_); } const_iterator begin() const { return const_iterator(data_); } - const_iterator end() const { return (data_ + size_); } + const_iterator end() const { return const_iterator(data_ + size_); } private: T data_[N]{}; diff --git a/src/lib/drishti/drishti/Context.hpp b/src/lib/drishti/drishti/Context.hpp index 76d7ba8b..ff96998c 100644 --- a/src/lib/drishti/drishti/Context.hpp +++ b/src/lib/drishti/drishti/Context.hpp @@ -6,10 +6,10 @@ \copyright Copyright 2014-2018 Elucideye, Inc. All rights reserved. \license{This project is released under the 3 Clause BSD License.} - This file contains the public API of the Context class. This class - will store and allocate internal state necessary for real time + This file contains the public API of the Context class. This class + will store and allocate internal state necessary for real time face tracking. - + */ #ifndef __drishti_drishti_Context_hpp__ @@ -27,12 +27,17 @@ _DRISHTI_SDK_BEGIN class DRISHTI_EXPORT Context { public: - + struct Impl; - Context(drishti::sdk::SensorModel& sensor); + explicit Context(drishti::sdk::SensorModel& sensor); ~Context(); + Context(const Context&) = delete; + Context(Context&&) = delete; + Context& operator=(const Context&) = delete; + Context& operator=(Context&&) = delete; + Impl* get() { return impl.get(); } void updateGL(); @@ -69,7 +74,7 @@ class DRISHTI_EXPORT Context void setDoCpuACF(bool flag); bool getDoCpuACF() const; - + void setDoAnnotation(bool flag); bool getDoAnnotation() const; diff --git a/src/lib/drishti/drishti/Eye.hpp b/src/lib/drishti/drishti/Eye.hpp index b0030918..b90e6731 100644 --- a/src/lib/drishti/drishti/Eye.hpp +++ b/src/lib/drishti/drishti/Eye.hpp @@ -39,8 +39,13 @@ class DRISHTI_EXPORT Eye }; Eye(); + ~Eye() = default; Eye(const Eye& src); + Eye(Eye&&) = default; + Eye& operator=(const Eye&) = default; + Eye& operator=(Eye&&) = default; + void setIris(const Ellipse& src) { iris = src; diff --git a/src/lib/drishti/drishti/EyeDetector.cpp b/src/lib/drishti/drishti/EyeDetector.cpp index 8ac227af..5b11f1f8 100644 --- a/src/lib/drishti/drishti/EyeDetector.cpp +++ b/src/lib/drishti/drishti/EyeDetector.cpp @@ -24,12 +24,17 @@ _DRISHTI_SDK_BEGIN struct EyeDetector::Impl { Impl() = default; - Impl(const std::string& filename) + explicit Impl(const std::string& filename) { init(filename); } ~Impl() = default; + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + void init(const std::string& filename) { m_detector = drishti::core::make_unique(filename); diff --git a/src/lib/drishti/drishti/EyeDetector.hpp b/src/lib/drishti/drishti/EyeDetector.hpp index 09f20f73..c14b76a5 100644 --- a/src/lib/drishti/drishti/EyeDetector.hpp +++ b/src/lib/drishti/drishti/EyeDetector.hpp @@ -41,8 +41,14 @@ class DRISHTI_EXPORT EyeDetector }; EyeDetector(); - EyeDetector(const std::string& filename); + explicit EyeDetector(const std::string& filename); ~EyeDetector(); + + EyeDetector(const EyeDetector&) = delete; + EyeDetector(EyeDetector&&) = delete; + EyeDetector& operator=(const EyeDetector&) = delete; + EyeDetector& operator=(EyeDetector&&) = delete; + int operator()(const Image3b& image, std::vector& objects); protected: diff --git a/src/lib/drishti/drishti/EyeIO.cpp b/src/lib/drishti/drishti/EyeIO.cpp index b18da968..4d41c024 100644 --- a/src/lib/drishti/drishti/EyeIO.cpp +++ b/src/lib/drishti/drishti/EyeIO.cpp @@ -60,7 +60,7 @@ void serialize(Archive& ar, drishti::sdk::Size2i& s, const unsigned int version) template void serialize(Archive& ar, drishti::sdk::Size2f& s, const unsigned int version) { - ar& GENERIC_NVP("width", s.width); + ar& GENERIC_NVP("width", s.width); // NOLINT (TODO) ar& GENERIC_NVP("height", s.height); } diff --git a/src/lib/drishti/drishti/EyeSegmenter.hpp b/src/lib/drishti/drishti/EyeSegmenter.hpp index 6d566d33..2754f4da 100644 --- a/src/lib/drishti/drishti/EyeSegmenter.hpp +++ b/src/lib/drishti/drishti/EyeSegmenter.hpp @@ -37,13 +37,14 @@ class DRISHTI_EXPORT EyeSegmenter { public: class Impl; - EyeSegmenter(const std::string& filename, ArchiveKind kind = kAuto); - EyeSegmenter(std::istream& is, ArchiveKind kind = kAuto); + explicit EyeSegmenter(const std::string& filename, ArchiveKind kind = kAuto); + explicit EyeSegmenter(std::istream& is, ArchiveKind kind = kAuto); // EyeSegmenter cannot be moved or copied: EyeSegmenter(const EyeSegmenter&) = delete; - EyeSegmenter& operator=(const EyeSegmenter&) = delete; EyeSegmenter(EyeSegmenter&&) = delete; + EyeSegmenter& operator=(const EyeSegmenter&) = delete; + EyeSegmenter& operator=(EyeSegmenter&&) = delete; ~EyeSegmenter(); diff --git a/src/lib/drishti/drishti/EyeSegmenterImpl.hpp b/src/lib/drishti/drishti/EyeSegmenterImpl.hpp index 011a0a33..185e1e19 100644 --- a/src/lib/drishti/drishti/EyeSegmenterImpl.hpp +++ b/src/lib/drishti/drishti/EyeSegmenterImpl.hpp @@ -29,10 +29,16 @@ _DRISHTI_SDK_BEGIN class DRISHTI_EXPORT EyeSegmenter::Impl { public: - Impl(bool doLoad = false); + explicit Impl(bool doLoad = false); Impl(const std::string& filename, ArchiveKind kind); Impl(std::istream& is, ArchiveKind kind); ~Impl(); + + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + int operator()(const Image3b& image, Eye& eye, bool isRight); Eye getMeanEye(int width) const; diff --git a/src/lib/drishti/drishti/FaceMonitorAdapter.h b/src/lib/drishti/drishti/FaceMonitorAdapter.h index f4ce0cf8..a0777d31 100644 --- a/src/lib/drishti/drishti/FaceMonitorAdapter.h +++ b/src/lib/drishti/drishti/FaceMonitorAdapter.h @@ -69,7 +69,7 @@ struct FaceMonitorAdapter : public drishti::hci::FaceMonitor using TimePoint = HighResolutionClock::time_point; // ; using Faces = std::vector; - FaceMonitorAdapter(drishti_face_tracker_t& table, int n = std::numeric_limits::max()) + explicit FaceMonitorAdapter(drishti_face_tracker_t& table, int n = std::numeric_limits::max()) : m_start(HighResolutionClock::now()) , m_table(table) , m_n(n) @@ -78,6 +78,11 @@ struct FaceMonitorAdapter : public drishti::hci::FaceMonitor ~FaceMonitorAdapter() = default; + FaceMonitorAdapter(const FaceMonitorAdapter&) = delete; + FaceMonitorAdapter(FaceMonitorAdapter&&) = delete; + FaceMonitorAdapter& operator=(const FaceMonitorAdapter&) = delete; + FaceMonitorAdapter& operator=(FaceMonitorAdapter&&) = delete; + static Request convert(const drishti_request_t &request) { return Request diff --git a/src/lib/drishti/drishti/FaceTracker.hpp b/src/lib/drishti/drishti/FaceTracker.hpp index 76452ecf..d82c0ce1 100644 --- a/src/lib/drishti/drishti/FaceTracker.hpp +++ b/src/lib/drishti/drishti/FaceTracker.hpp @@ -113,7 +113,7 @@ using drishti_image_t = drishti_image; * the desired format: (1) OpenGL texture or; (2) user memory. */ -typedef struct drishti_request +struct drishti_request_t { /** * Retrieve the last N frames. @@ -140,15 +140,13 @@ typedef struct drishti_request */ bool getEyes; -} drishti_request_t; - -using drishti_request_t = drishti_request; +}; /** * An alias for a vector of drishti_face_tracker_result_t objects. */ -typedef drishti::sdk::Array drishti_face_tracker_results_t; +using drishti_face_tracker_results_t = drishti::sdk::Array; // User defined callbacks: @@ -263,8 +261,9 @@ class DRISHTI_EXPORT FaceTracker // FaceTracker cannot be moved or copied: FaceTracker(const FaceTracker&) = delete; - FaceTracker& operator=(const FaceTracker&) = delete; FaceTracker(FaceTracker&&) = delete; + FaceTracker& operator=(const FaceTracker&) = delete; + FaceTracker& operator=(FaceTracker&&) = delete; /** * Destructor diff --git a/src/lib/drishti/drishti/Image.hpp b/src/lib/drishti/drishti/Image.hpp index b0c2e72c..cd336836 100644 --- a/src/lib/drishti/drishti/Image.hpp +++ b/src/lib/drishti/drishti/Image.hpp @@ -87,6 +87,7 @@ template struct Matrix { Matrix() = default; + ~Matrix() = default; Matrix(const Matrix& src) { for (int y = 0; y < rowDim; y++) @@ -98,6 +99,10 @@ struct Matrix } } + Matrix(Matrix&&) noexcept = default; + Matrix& operator=(const Matrix&) = delete; + Matrix& operator=(Matrix&&) = delete; + int rows() const { return rowDim; } int cols() const { return colDim; } @@ -121,7 +126,7 @@ struct Matrix T data[rowDim][colDim]; }; -typedef Matrix Matrix33f; +using Matrix33f = Matrix; /* * Rect types @@ -186,6 +191,11 @@ class DRISHTI_EXPORT Image Image(const Image& src); Image(size_t rows, size_t cols, T* data, size_t stride, bool keep = false); ~Image(); + + Image(Image&&) noexcept = default; + Image& operator=(const Image&) = default; + Image& operator=(Image&&) noexcept = default; + size_t getRows() const { return rows; @@ -201,7 +211,7 @@ class DRISHTI_EXPORT Image template const T2* ptr() const { - return reinterpret_cast(data); + return reinterpret_cast(data); // NOLINT (TODO) } Image clone(); diff --git a/src/lib/drishti/drishti/Sensor.cpp b/src/lib/drishti/drishti/Sensor.cpp index a7244608..c937829e 100644 --- a/src/lib/drishti/drishti/Sensor.cpp +++ b/src/lib/drishti/drishti/Sensor.cpp @@ -19,6 +19,7 @@ #include #include +#include _DRISHTI_SDK_BEGIN @@ -35,8 +36,8 @@ SensorModel::Intrinsic::Intrinsic(const Vec2f& c, float fx, const Vec2i& size) { } -SensorModel::Extrinsic::Extrinsic(const Matrix33f& R) - : m_R(R) +SensorModel::Extrinsic::Extrinsic(Matrix33f R) + : m_R(std::move(R)) { } diff --git a/src/lib/drishti/drishti/Sensor.hpp b/src/lib/drishti/drishti/Sensor.hpp index 58272b98..d8548c0b 100644 --- a/src/lib/drishti/drishti/Sensor.hpp +++ b/src/lib/drishti/drishti/Sensor.hpp @@ -34,13 +34,18 @@ class DRISHTI_EXPORT SensorModel // ### Extrinsic camera parameters: struct DRISHTI_EXPORT Extrinsic { - Extrinsic(const Matrix33f& R); + Extrinsic(Matrix33f R); Matrix33f m_R; }; SensorModel(const Intrinsic& intrinsic, const Extrinsic& extrinsic); ~SensorModel(); + SensorModel(const SensorModel&) = delete; + SensorModel(SensorModel&&) = delete; + SensorModel& operator=(const SensorModel&) = delete; + SensorModel& operator=(SensorModel&&) = delete; + struct Impl; std::unique_ptr& getImpl() diff --git a/src/lib/drishti/drishti/ut/test-EyeSegmenter.cpp b/src/lib/drishti/drishti/ut/test-EyeSegmenter.cpp index 28b2a93b..d29ef9af 100644 --- a/src/lib/drishti/drishti/ut/test-EyeSegmenter.cpp +++ b/src/lib/drishti/drishti/ut/test-EyeSegmenter.cpp @@ -54,6 +54,11 @@ static drishti::sdk::ArchiveKind getArchiveKind(const std::string& filename) class EyeSegmenterTest : public ::testing::Test { public: + EyeSegmenterTest(const EyeSegmenterTest&) = delete; + EyeSegmenterTest(EyeSegmenterTest&&) = delete; + EyeSegmenterTest& operator=(const EyeSegmenterTest&) = delete; + EyeSegmenterTest& operator=(EyeSegmenterTest&&) = delete; + static std::shared_ptr create(const std::string& filename) { if (isArchiveSupported(filename)) @@ -102,7 +107,7 @@ class EyeSegmenterTest : public ::testing::Test using Vec3b = drishti::sdk::Vec3b; using Image3b = drishti::sdk::Image3b; - struct Entry + struct Entry // NOLINT (TODO) { Image3b image; cv::Mat storage; @@ -125,15 +130,13 @@ class EyeSegmenterTest : public ::testing::Test } // Cleanup - virtual ~EyeSegmenterTest() - { - } + ~EyeSegmenterTest() override = default; // Called after constructor for each test - virtual void SetUp() {} + void SetUp() override {} // Called after destructor for each test - virtual void TearDown() {} + void TearDown() override {} // Utility methods: void loadImages() @@ -166,7 +169,7 @@ class EyeSegmenterTest : public ::testing::Test cv::Mat resized; if (width > 0) { - int height = static_cast(static_cast(width) / m_eyeSegmenter->getRequiredAspectRatio() + 0.5f); + auto height = static_cast(static_cast(width) / m_eyeSegmenter->getRequiredAspectRatio() + 0.5f); cv::resize(padded, resized, { width, height }, width); } @@ -219,22 +222,22 @@ class EyeSegmenterTest : public ::testing::Test * Basic class construction */ -TEST(EyeSegmenter, StringConstructor) +TEST(EyeSegmenter, StringConstructor) // NOLINT (TODO) { if (isArchiveSupported(sEyeRegressor)) { - ASSERT_NE(sEyeRegressor, (const char*)NULL); + ASSERT_NE(sEyeRegressor, (const char*)nullptr); auto segmenter = EyeSegmenterTest::create(sEyeRegressor); ASSERT_EQ(segmenter && segmenter->good(), true); } } -TEST(EyeSegmenter, StreamConstructor) +TEST(EyeSegmenter, StreamConstructor) // NOLINT (TODO) { if (isArchiveSupported(sEyeRegressor)) { // Make sure sEyeRegressor is not null: - ASSERT_NE(sEyeRegressor, (const char*)NULL); + ASSERT_NE(sEyeRegressor, (const char*)nullptr); std::ifstream is(sEyeRegressor, std::ios_base::binary | std::ios::in); ASSERT_TRUE((bool)is); drishti::sdk::EyeSegmenter segmenter(is, getArchiveKind(sEyeRegressor)); @@ -262,7 +265,7 @@ static void checkInvalid(const drishti::sdk::Eye& eye) * Fixture tests */ -TEST_F(EyeSegmenterTest, EyeSerialization) +TEST_F(EyeSegmenterTest, EyeSerialization) // NOLINT (TODO) { int targetWidth = 128; drishti::sdk::Eye eye; @@ -290,13 +293,13 @@ TEST_F(EyeSegmenterTest, EyeSerialization) if (os) { cereal::JSONOutputArchive oa(os); - typedef decltype(oa) Archive; + using Archive = decltype(oa); oa << GENERIC_NVP("eye", privateEye); } } } -TEST_F(EyeSegmenterTest, ImageEmpty) +TEST_F(EyeSegmenterTest, ImageEmpty) // NOLINT (TODO) { for (const auto& entry : m_images) { @@ -312,7 +315,7 @@ TEST_F(EyeSegmenterTest, ImageEmpty) } } -TEST_F(EyeSegmenterTest, ImageTooSmall) +TEST_F(EyeSegmenterTest, ImageTooSmall) // NOLINT (TODO) { for (const auto& entry : m_images) { @@ -330,7 +333,7 @@ TEST_F(EyeSegmenterTest, ImageTooSmall) // TODO: Add ground truth comparison // * hamming distance for sclera and iris masks components -TEST_F(EyeSegmenterTest, ImageValid) +TEST_F(EyeSegmenterTest, ImageValid) // NOLINT (TODO) { for (auto iter = getFirstValid(); iter != m_images.end(); iter++) { @@ -355,11 +358,11 @@ TEST_F(EyeSegmenterTest, ImageValid) } // Currently there is no internal quality check, but this is included for regression: -TEST_F(EyeSegmenterTest, ImageIsBlack) +TEST_F(EyeSegmenterTest, ImageIsBlack) // NOLINT (TODO) { Entry entry; const int width = 256; - const int height = static_cast(static_cast(width) / m_eyeSegmenter->getRequiredAspectRatio() + 0.5f); + const auto height = static_cast(static_cast(width) / m_eyeSegmenter->getRequiredAspectRatio() + 0.5f); createImage(entry, height, width, { 0, 0, 0 }); drishti::sdk::Eye eye; @@ -368,12 +371,12 @@ TEST_F(EyeSegmenterTest, ImageIsBlack) checkValid(eye, entry.storage.size()); } -TEST_F(EyeSegmenterTest, ImageIsWhite) +TEST_F(EyeSegmenterTest, ImageIsWhite) // NOLINT (TODO) { Entry entry; const int width = 256; - const int height = static_cast(static_cast(width) / m_eyeSegmenter->getRequiredAspectRatio() + 0.5f); + const auto height = static_cast(static_cast(width) / m_eyeSegmenter->getRequiredAspectRatio() + 0.5f); createImage(entry, height, width, { 0, 0, 0 }); drishti::sdk::Eye eye; diff --git a/src/lib/drishti/drishti/ut/test-FaceTracker.cpp b/src/lib/drishti/drishti/ut/test-FaceTracker.cpp index 03758e88..34cb22c2 100644 --- a/src/lib/drishti/drishti/ut/test-FaceTracker.cpp +++ b/src/lib/drishti/drishti/ut/test-FaceTracker.cpp @@ -50,19 +50,15 @@ extern const char* sFaceImageFilename; BEGIN_EMPTY_NAMESPACE -struct WaitKey -{ - WaitKey() {} - ~WaitKey() - { -#if DRISHTI_HCI_TEST_DISPLAY_OUTPUT - cv::waitKey(0); -#endif - } -}; - class FaceTest : public ::testing::Test { +public: + + FaceTest(const FaceTest&) = delete; + FaceTest(FaceTest&&) = delete; + FaceTest& operator=(const FaceTest&) = delete; + FaceTest& operator=(FaceTest&&) = delete; + protected: bool m_hasTranspose = false; @@ -87,7 +83,7 @@ class FaceTest : public ::testing::Test } // Cleanup - virtual ~FaceTest() + ~FaceTest() override { drishti::core::Logger::drop("test-drishti-drishti-face"); } @@ -298,10 +294,10 @@ class FaceTest : public ::testing::Test #endif // DRISHTI_BUILD_C_INTERFACE // Called after constructor for each test - virtual void SetUp() {} + void SetUp() override {} // Called after destructor for each test - virtual void TearDown() {} + void TearDown() override {} static cv::Mat loadImage(const std::string& filename) { @@ -327,7 +323,7 @@ class FaceTest : public ::testing::Test }; #if defined(DRISHTI_DO_GPU_TESTING) -TEST_F(FaceTest, RunSimpleTest) +TEST_F(FaceTest, RunSimpleTest) // NOLINT (TODO) { static const bool doCpu = false; static const bool doAsync = true; diff --git a/src/lib/drishti/eye/Eye.h b/src/lib/drishti/eye/Eye.h index 88d78143..d33b0acc 100644 --- a/src/lib/drishti/eye/Eye.h +++ b/src/lib/drishti/eye/Eye.h @@ -41,6 +41,12 @@ struct EyeModel EyeModel(); ~EyeModel(); + // TODO (?) + EyeModel(const EyeModel&) = default; + EyeModel(EyeModel&&) = default; + EyeModel& operator=(const EyeModel&) = default; + EyeModel& operator=(EyeModel&&) = default; + const cv::Point2f& getOuterCorner() const { return eyelids[cornerIndices[0]]; diff --git a/src/lib/drishti/eye/EyeModelEstimator.h b/src/lib/drishti/eye/EyeModelEstimator.h index 8be22abf..170d00ad 100644 --- a/src/lib/drishti/eye/EyeModelEstimator.h +++ b/src/lib/drishti/eye/EyeModelEstimator.h @@ -35,11 +35,16 @@ class EyeModelEstimator }; EyeModelEstimator(); - EyeModelEstimator(const std::string& filename); - EyeModelEstimator(std::istream& is, const std::string& hint = {}); - EyeModelEstimator(const RegressorConfig& config); + explicit EyeModelEstimator(const std::string& filename); + explicit EyeModelEstimator(std::istream& is, const std::string& hint = {}); + explicit EyeModelEstimator(const RegressorConfig& config); ~EyeModelEstimator(); + EyeModelEstimator(const EyeModelEstimator&) = delete; + EyeModelEstimator(EyeModelEstimator&&) = delete; + EyeModelEstimator& operator=(const EyeModelEstimator&) = delete; + EyeModelEstimator& operator=(EyeModelEstimator&&) = delete; + bool good() const; operator bool() const; diff --git a/src/lib/drishti/eye/EyeModelEstimatorImpl.h b/src/lib/drishti/eye/EyeModelEstimatorImpl.h index 6633838a..b476fb08 100644 --- a/src/lib/drishti/eye/EyeModelEstimatorImpl.h +++ b/src/lib/drishti/eye/EyeModelEstimatorImpl.h @@ -40,10 +40,15 @@ class EyeModelEstimator::Impl Impl(); - Impl(const std::string& eyeRegressor, const std::string& irisRegressor = {}, const std::string& pupilRegressor = {}); + explicit Impl(const std::string& eyeRegressor, const std::string& irisRegressor = {}, const std::string& pupilRegressor = {}); ~Impl(); + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + void init(); void setStreamLogger(std::shared_ptr& logger); diff --git a/src/lib/drishti/eye/EyeModelIris.cpp b/src/lib/drishti/eye/EyeModelIris.cpp index d40c1399..1fcabbc6 100644 --- a/src/lib/drishti/eye/EyeModelIris.cpp +++ b/src/lib/drishti/eye/EyeModelIris.cpp @@ -119,7 +119,8 @@ EyeModelEstimator::Impl::estimateCentralIris(const cv::Mat& I, const cv::Mat& M, static cv::RotatedRect ellipseFromCircle(const cv::Point2f& c, float radius, float theta) { - return cv::RotatedRect(c, { radius * 2.f, radius * 2.f }, theta * 180.0 / M_PI); + const float angle = theta * 180.0 / M_PI; + return { c, { radius * 2.f, radius * 2.f }, angle }; } // Note: The inner corner should be most stable: diff --git a/src/lib/drishti/eye/EyeModelPupil.cpp b/src/lib/drishti/eye/EyeModelPupil.cpp index bc1130ef..deb364ed 100644 --- a/src/lib/drishti/eye/EyeModelPupil.cpp +++ b/src/lib/drishti/eye/EyeModelPupil.cpp @@ -58,7 +58,7 @@ void EyeModelEstimator::Impl::segmentPupil(const cv::Mat& I, EyeModel& eye, int std::vector pupils; const float minScale = radius * 1.f / 4.f; const float maxScale = radius * 1.f / 2.f; - for (float s = minScale; s <= maxScale; s *= 1.05f) + for (float s = minScale; s <= maxScale; s *= 1.05f) // NOLINT (TODO) { pupils.emplace_back(pupil.center, cv::Size2f(s, s) * scale, pupil.angle); } diff --git a/src/lib/drishti/eye/gpu/EyeWarp.h b/src/lib/drishti/eye/gpu/EyeWarp.h index e9161c6f..3624f6c1 100644 --- a/src/lib/drishti/eye/gpu/EyeWarp.h +++ b/src/lib/drishti/eye/gpu/EyeWarp.h @@ -14,6 +14,7 @@ #include "drishti/eye/Eye.h" #include +#include DRISHTI_EYE_NAMESPACE_BEGIN @@ -25,10 +26,10 @@ struct EyeWarp , H(H) { } - EyeWarp(const cv::Rect2f& roi, const cv::Matx33f& H, const DRISHTI_EYE::EyeModel& eye) + EyeWarp(const cv::Rect2f& roi, const cv::Matx33f& H, DRISHTI_EYE::EyeModel eye) : roi(roi) , H(H) - , eye(eye) + , eye(std::move(eye)) { } cv::Rect2f roi; diff --git a/src/lib/drishti/eye/ut/test-drishti-eye.cpp b/src/lib/drishti/eye/ut/test-drishti-eye.cpp index 14b95777..ea8f073f 100644 --- a/src/lib/drishti/eye/ut/test-drishti-eye.cpp +++ b/src/lib/drishti/eye/ut/test-drishti-eye.cpp @@ -57,8 +57,13 @@ class EyeModelEstimatorTest : public ::testing::Test return (segmenter && segmenter->good()) ? segmenter : nullptr; } + EyeModelEstimatorTest(const EyeModelEstimatorTest&) = delete; + EyeModelEstimatorTest(EyeModelEstimatorTest&&) = delete; + EyeModelEstimatorTest& operator=(const EyeModelEstimatorTest&) = delete; + EyeModelEstimatorTest& operator=(EyeModelEstimatorTest&&) = delete; + protected: - struct Entry + struct Entry // NOLINT (TODO) { cv::Mat image; bool isRight; @@ -78,15 +83,13 @@ class EyeModelEstimatorTest : public ::testing::Test } // Cleanup - virtual ~EyeModelEstimatorTest() - { - } + ~EyeModelEstimatorTest() override = default; // Called after constructor for each test - virtual void SetUp() {} + void SetUp() override {} // Called after destructor for each test - virtual void TearDown() {} + void TearDown() override {} // Utility methods: void loadImages() @@ -122,7 +125,7 @@ class EyeModelEstimatorTest : public ::testing::Test cv::Mat resized; if (width > 0) { - const int height = static_cast(static_cast(width) / EYE_ASPECT_RATIO + 0.5f); + const auto height = static_cast(static_cast(width) / EYE_ASPECT_RATIO + 0.5f); cv::resize(padded, resized, { width, height }, width); } @@ -138,7 +141,7 @@ class EyeModelEstimatorTest : public ::testing::Test { auto eye = std::make_shared(); cereal::JSONInputArchive ia(is); - typedef decltype(ia) Archive; + using Archive = decltype(ia); ia(GENERIC_NVP("eye", *eye)); m_eye = eye; m_eye->refine(); @@ -198,21 +201,21 @@ static bool isEqual(const drishti::eye::EyeModel& eyeA, const drishti::eye::EyeM * Basic class construction */ -TEST(EyeModelEstimator, StringConstructor) +TEST(EyeModelEstimator, StringConstructor) // NOLINT (TODO) { if (isArchiveSupported(sEyeModelPrivateFilename)) { - ASSERT_NE(sEyeModelPrivateFilename, (const char*)NULL); + ASSERT_NE(sEyeModelPrivateFilename, (const char*)nullptr); auto segmenter = EyeModelEstimatorTest::create(sEyeModelPrivateFilename); ASSERT_EQ(segmenter->good(), true); } } -TEST(EyeModelEstimator, StreamConstructor) +TEST(EyeModelEstimator, StreamConstructor) // NOLINT (TODO) { if (isArchiveSupported(sEyeModelPrivateFilename)) { - ASSERT_NE(sEyeModelPrivateFilename, (const char*)NULL); + ASSERT_NE(sEyeModelPrivateFilename, (const char*)nullptr); std::ifstream is(sEyeModelPrivateFilename); ASSERT_TRUE((bool)is); auto segmenter = EyeModelEstimatorTest::create(sEyeModelPrivateFilename); @@ -220,7 +223,7 @@ TEST(EyeModelEstimator, StreamConstructor) } } -TEST_F(EyeModelEstimatorTest, CerealSerialization) +TEST_F(EyeModelEstimatorTest, CerealSerialization) // NOLINT (TODO) { std::string filename = std::string(sOutputDirectory) + "/eye.cpb"; save_cpb(filename, *m_eyeSegmenter); @@ -233,7 +236,7 @@ TEST_F(EyeModelEstimatorTest, CerealSerialization) * Fixture tests */ -TEST_F(EyeModelEstimatorTest, EyeSerialization) +TEST_F(EyeModelEstimatorTest, EyeSerialization) // NOLINT (TODO) { drishti::eye::EyeModel eye; @@ -245,12 +248,12 @@ TEST_F(EyeModelEstimatorTest, EyeSerialization) std::ofstream os(filename); cereal::JSONOutputArchive oa(os); - typedef decltype(oa) Archive; + using Archive = decltype(oa); oa << GENERIC_NVP("eye", eye); } // * hamming distance for sclera and iris masks components -TEST_F(EyeModelEstimatorTest, ImageValid) +TEST_F(EyeModelEstimatorTest, ImageValid) // NOLINT (TODO) { if (!m_eye || !m_eyeSegmenter) { @@ -280,7 +283,7 @@ TEST_F(EyeModelEstimatorTest, ImageValid) } } -TEST_F(EyeModelEstimatorTest, IsRepeatable) +TEST_F(EyeModelEstimatorTest, IsRepeatable) // NOLINT (TODO) { if (!m_eye || !m_eyeSegmenter) { @@ -310,11 +313,11 @@ TEST_F(EyeModelEstimatorTest, IsRepeatable) } // Currently there is no internal quality check, but this is included for regression: -TEST_F(EyeModelEstimatorTest, ImageIsBlack) +TEST_F(EyeModelEstimatorTest, ImageIsBlack) // NOLINT (TODO) { Entry entry; const int width = 128; - const int height = static_cast(static_cast(width) / EYE_ASPECT_RATIO + 0.5f); + const auto height = static_cast(static_cast(width) / EYE_ASPECT_RATIO + 0.5f); createImage(entry, height, width, { 0, 0, 0 }); assert(entry.isRight); @@ -324,11 +327,11 @@ TEST_F(EyeModelEstimatorTest, ImageIsBlack) checkValid(eye, entry.image.size()); } -TEST_F(EyeModelEstimatorTest, ImageIsWhite) +TEST_F(EyeModelEstimatorTest, ImageIsWhite) // NOLINT (TODO) { Entry entry; const int width = 128; - const int height = static_cast(static_cast(width) / EYE_ASPECT_RATIO + 0.5f); + const auto height = static_cast(static_cast(width) / EYE_ASPECT_RATIO + 0.5f); createImage(entry, height, width, { 0, 0, 0 }); assert(entry.isRight); diff --git a/src/lib/drishti/face/Face.h b/src/lib/drishti/face/Face.h index a954180d..8f9e7ec6 100644 --- a/src/lib/drishti/face/Face.h +++ b/src/lib/drishti/face/Face.h @@ -35,6 +35,12 @@ struct FaceModel ~FaceModel(); + // TODO (?) + FaceModel(const FaceModel&) = default; + FaceModel(FaceModel&&) = default; + FaceModel& operator=(const FaceModel&) = default; + FaceModel& operator=(FaceModel&&) = default; + float getInterPupillaryDistance() const; cv::Point2f getEyeLeftCenter() const; cv::Point2f getEyeRightCenter() const; diff --git a/src/lib/drishti/face/FaceDetector.cpp b/src/lib/drishti/face/FaceDetector.cpp index 25ff1e33..31f833da 100644 --- a/src/lib/drishti/face/FaceDetector.cpp +++ b/src/lib/drishti/face/FaceDetector.cpp @@ -52,6 +52,11 @@ class FaceDetector::Impl ~Impl() = default; + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + void create(FaceDetectorFactory& resources) { m_detector = resources.getFaceDetector(); @@ -607,9 +612,9 @@ void FaceDetector::setFaceDetectorMean(const FaceModel& mu) { m_impl->setFaceDetectorMean(mu); } -void FaceDetector::setLogger(MatLoggerType logger) +void FaceDetector::setLogger(const MatLoggerType& logger) { - m_impl->setLogger(std::move(logger)); + m_impl->setLogger(logger); } drishti::ml::ObjectDetector* FaceDetector::getDetector() { diff --git a/src/lib/drishti/face/FaceDetector.h b/src/lib/drishti/face/FaceDetector.h index 7eeaa51e..0a0cffdc 100644 --- a/src/lib/drishti/face/FaceDetector.h +++ b/src/lib/drishti/face/FaceDetector.h @@ -48,13 +48,19 @@ class FaceDetector struct PaddedImage { PaddedImage() = default; - PaddedImage(cv::Mat Ib, const cv::Rect& roi = {}) + explicit PaddedImage(cv::Mat Ib, const cv::Rect& roi = {}) : Ib(std::move(Ib)) , roi(roi) { } - PaddedImage& operator=(const PaddedImage& I) - = default; + PaddedImage& operator=(const PaddedImage&) = default; + + PaddedImage(const PaddedImage&) = delete; + PaddedImage(PaddedImage&&) = delete; + PaddedImage& operator =(PaddedImage&&) = default; + + ~PaddedImage() = default; + operator cv::Mat() { return Ib; @@ -63,16 +69,21 @@ class FaceDetector cv::Rect roi; }; - typedef std::function(const cv::Point2f& L, const cv::Point2f& R)> EyeCropper; + using EyeCropper = std::function(const cv::Point2f& L, const cv::Point2f& R)>; using MatLoggerType = std::function; using TimeLoggerType = std::function; class Impl; using Landmarks = std::vector; - FaceDetector(FaceDetectorFactory& Resources); + explicit FaceDetector(FaceDetectorFactory& Resources); ~FaceDetector(); + FaceDetector(const FaceDetector&) = delete; + FaceDetector(FaceDetector&&) = delete; + FaceDetector& operator=(const FaceDetector&) = delete; + FaceDetector& operator=(FaceDetector&&) = delete; + void setLandmarkFormat(FaceSpecification::Format format); virtual void operator()(const MatP& I, const PaddedImage& Ib, std::vector& faces, const cv::Matx33f& H = EYE); @@ -107,7 +118,7 @@ class FaceDetector void setDetectionTimeLogger(TimeLoggerType logger); void setRegressionTimeLogger(TimeLoggerType logger); void setEyeRegressionTimeLogger(TimeLoggerType logger); - void setLogger(MatLoggerType logger); + void setLogger(const MatLoggerType& logger); void setHrd(const cv::Matx33f& Hrd); // regression face => detection face void setEyeCropper(EyeCropper& cropper); void paint(cv::Mat& frame); diff --git a/src/lib/drishti/face/FaceDetectorAndTrackerImpl.h b/src/lib/drishti/face/FaceDetectorAndTrackerImpl.h index bab657b8..49c891b6 100644 --- a/src/lib/drishti/face/FaceDetectorAndTrackerImpl.h +++ b/src/lib/drishti/face/FaceDetectorAndTrackerImpl.h @@ -36,6 +36,11 @@ class FaceDetectorAndTracker::TrackImpl TrackImpl(); ~TrackImpl(); + TrackImpl(const TrackImpl&) = delete; + TrackImpl(TrackImpl&&) = delete; + TrackImpl& operator=(const TrackImpl&) = delete; + TrackImpl& operator=(TrackImpl&&) = delete; + /* * This will update cv::Rect eyeFull{L,R}::roi */ diff --git a/src/lib/drishti/face/FaceDetectorAndTrackerNN.h b/src/lib/drishti/face/FaceDetectorAndTrackerNN.h index 9757df42..7fcdf4d5 100644 --- a/src/lib/drishti/face/FaceDetectorAndTrackerNN.h +++ b/src/lib/drishti/face/FaceDetectorAndTrackerNN.h @@ -20,6 +20,12 @@ class TrackerNN : public FaceDetectorAndTracker::TrackImpl public: TrackerNN(); ~TrackerNN(); + + TrackerNN(const TrackerNN&) = delete; + TrackerNN(TrackerNN&&) = delete; + TrackerNN& operator=(const TrackerNN&) = delete; + TrackerNN& operator=(TrackerNN&&) = delete; + void initialize(const cv::Mat1b& image, const FaceModel& face) override; bool update(const cv::Mat1b& image, FaceModel& face) override; std::vector getFeatures() const override; diff --git a/src/lib/drishti/face/FaceTracker.h b/src/lib/drishti/face/FaceTracker.h index e9743eb6..c70877d3 100644 --- a/src/lib/drishti/face/FaceTracker.h +++ b/src/lib/drishti/face/FaceTracker.h @@ -58,8 +58,14 @@ class FaceTracker struct Impl; - FaceTracker(float costThreshold = 0.15f, std::size_t minTrackHits = 3, std::size_t maxTrackMisses = 3); + explicit FaceTracker(float costThreshold = 0.15f, std::size_t minTrackHits = 3, std::size_t maxTrackMisses = 3); ~FaceTracker(); + + FaceTracker(const FaceTracker&) = delete; + FaceTracker(FaceTracker&&) = delete; + FaceTracker& operator=(const FaceTracker&) = delete; + FaceTracker& operator=(FaceTracker&&) = delete; + void operator()(const FaceModelVec& facesIn, FaceTrackVec& facesOut); protected: diff --git a/src/lib/drishti/face/gpu/EyeFilter.h b/src/lib/drishti/face/gpu/EyeFilter.h index 0a24b779..69e8492f 100644 --- a/src/lib/drishti/face/gpu/EyeFilter.h +++ b/src/lib/drishti/face/gpu/EyeFilter.h @@ -56,6 +56,11 @@ class EyeFilter : public ogles_gpgpu::MultiPassProc ~EyeFilter() override; + EyeFilter(const EyeFilter&) = delete; + EyeFilter(EyeFilter&&) = delete; + EyeFilter& operator=(const EyeFilter&) = delete; + EyeFilter& operator=(EyeFilter&&) = delete; + void setAutoScaling(bool flag) { m_doAutoScaling = flag; diff --git a/src/lib/drishti/face/gpu/MultiTransformProc.cpp b/src/lib/drishti/face/gpu/MultiTransformProc.cpp index 76e12c15..4e0af6c3 100644 --- a/src/lib/drishti/face/gpu/MultiTransformProc.cpp +++ b/src/lib/drishti/face/gpu/MultiTransformProc.cpp @@ -19,7 +19,7 @@ void MultiTransformProc::renderRegion(const Rect2d& dstRoiPix, const Mat44f& H) // Limit warping to desired eye crop region glScissor(dstRoiPix.x, dstRoiPix.y, dstRoiPix.width, dstRoiPix.height); - glUniformMatrix4fv(shParamUTransform, 1, 0, (GLfloat*)&H.data[0]); + glUniformMatrix4fv(shParamUTransform, 1, 0, (GLfloat*)&H.data[0]); // NOLINT (TODO) Tools::checkGLErr(getProcName(), "MultiTransformProc::renderEye() : glUniformMatrix4fv()"); glDrawArrays(GL_TRIANGLE_STRIP, 0, OGLES_GPGPU_QUAD_VERTICES); diff --git a/src/lib/drishti/face/gpu/MultiTransformProc.h b/src/lib/drishti/face/gpu/MultiTransformProc.h index 2a4a29af..b91d3a47 100644 --- a/src/lib/drishti/face/gpu/MultiTransformProc.h +++ b/src/lib/drishti/face/gpu/MultiTransformProc.h @@ -27,6 +27,11 @@ class MultiTransformProc : public ogles_gpgpu::TransformProc MultiTransformProc() = default; ~MultiTransformProc() override = default; + MultiTransformProc(const MultiTransformProc&) = delete; + MultiTransformProc(MultiTransformProc&&) = delete; + MultiTransformProc& operator=(const MultiTransformProc&) = delete; + MultiTransformProc& operator=(MultiTransformProc&&) = delete; + void renderRegion(const Rect2d& dstRoiPix, const Mat44f& Heye); void filterRenderDraw() override; diff --git a/src/lib/drishti/face/ut/test-drishti-face.cpp b/src/lib/drishti/face/ut/test-drishti-face.cpp index 8d8d847f..30e84ff9 100644 --- a/src/lib/drishti/face/ut/test-drishti-face.cpp +++ b/src/lib/drishti/face/ut/test-drishti-face.cpp @@ -32,6 +32,13 @@ BEGIN_EMPTY_NAMESPACE class FaceDetectorTest : public ::testing::Test { +public: + + FaceDetectorTest(const FaceDetectorTest&) = delete; + FaceDetectorTest(FaceDetectorTest&&) = delete; + FaceDetectorTest& operator=(const FaceDetectorTest&) = delete; + FaceDetectorTest& operator=(FaceDetectorTest&&) = delete; + protected: // Setup @@ -57,16 +64,16 @@ class FaceDetectorTest : public ::testing::Test } // Cleanup - virtual ~FaceDetectorTest() + ~FaceDetectorTest() override { drishti::core::Logger::drop("test-drishti-face"); } // Called after constructor for each test - virtual void SetUp() {} + void SetUp() override {} // Called after destructor for each test - virtual void TearDown() {} + void TearDown() override {} cv::Mat loadImage(const std::string& filename) { @@ -96,7 +103,7 @@ class FaceDetectorTest : public ::testing::Test std::shared_ptr m_detector; }; -TEST_F(FaceDetectorTest, FaceDetector) +TEST_F(FaceDetectorTest, FaceDetector) // NOLINT (TODO) { std::vector faces; (*m_detector)(Ip, Ib, faces, cv::Matx33f::eye()); diff --git a/src/lib/drishti/geometry/Cylinder.h b/src/lib/drishti/geometry/Cylinder.h index 98f78194..84589626 100644 --- a/src/lib/drishti/geometry/Cylinder.h +++ b/src/lib/drishti/geometry/Cylinder.h @@ -22,6 +22,7 @@ class Cylinder3D { public: Cylinder3D() = default; + ~Cylinder3D() = default; Cylinder3D(const Cylinder3D& src) : position(src.position) @@ -37,6 +38,10 @@ class Cylinder3D { } + Cylinder3D(Cylinder3D&&) = delete; + Cylinder3D& operator=(const Cylinder3D&) = delete; + Cylinder3D& operator=(Cylinder3D&&) = delete; + const cv::Point3_& getPosition() const { return position; } T getRadius() const { return radius; } T getLength() const { return length; } diff --git a/src/lib/drishti/geometry/Ellipse.h b/src/lib/drishti/geometry/Ellipse.h index 0243b1e3..c6666395 100644 --- a/src/lib/drishti/geometry/Ellipse.h +++ b/src/lib/drishti/geometry/Ellipse.h @@ -6,8 +6,8 @@ \copyright Copyright 2014-2016 Elucideye, Inc. All rights reserved. \license{This file is released under the 3 Clause BSD License (exceptions noted below)} - 1) class Conicsection_ - License: MIT + 1) class Conicsection_ + License: MIT https://github.com/LeszekSwirski/pupiltracker/ 2) cv::RotatedRect ConicSection_::getEllipse() @@ -34,11 +34,16 @@ class Ellipse : public cv::RotatedRect { public: Ellipse() = default; + ~Ellipse() = default; Ellipse(const Ellipse& src); Ellipse(const cv::Vec6d& par); Ellipse(const cv::RotatedRect& cen); Ellipse(const cv::RotatedRect& cen, const cv::Vec6d& par); + Ellipse(Ellipse&&) = delete; + Ellipse& operator=(const Ellipse&) = delete; + Ellipse& operator=(Ellipse&&) = delete; + const cv::Vec6d& getParametric() const { return m_par; @@ -141,12 +146,12 @@ inline std::vector ellipseToPoints(const cv::RotatedRect& e) inline cv::RotatedRect pointsToEllipse(const cv::Point2f* p) { - return cv::RotatedRect({ p[0].x, p[1].x }, { p[2].x, p[3].x }, p[4].x); + return {{ p[0].x, p[1].x }, { p[2].x, p[3].x }, p[4].x}; } inline cv::RotatedRect pointsToEllipse(const std::vector& p) { - return cv::RotatedRect({ p[0].x, p[1].x }, { p[2].x, p[3].x }, p[4].x); + return {{ p[0].x, p[1].x }, { p[2].x, p[3].x }, p[4].x}; } inline std::vector pointsToEllipses(const std::vector& p) diff --git a/src/lib/drishti/geometry/Mesh3D.h b/src/lib/drishti/geometry/Mesh3D.h index 80c69a74..455628fb 100644 --- a/src/lib/drishti/geometry/Mesh3D.h +++ b/src/lib/drishti/geometry/Mesh3D.h @@ -29,11 +29,15 @@ class Mesh3D : m_vertices(mesh.m_vertices) { } - Mesh3D(Mesh3D&& mesh) + Mesh3D(Mesh3D&& mesh) noexcept : m_vertices(std::move(mesh.m_vertices)) { } + Mesh3D& operator=(Mesh3D&&) = delete; + + ~Mesh3D() = default; + Mesh3D& operator=(const Mesh3D& src) { this->m_vertices = src.m_vertices; diff --git a/src/lib/drishti/geometry/Primitives.cpp b/src/lib/drishti/geometry/Primitives.cpp index a880b23e..289a84c5 100644 --- a/src/lib/drishti/geometry/Primitives.cpp +++ b/src/lib/drishti/geometry/Primitives.cpp @@ -49,7 +49,7 @@ cv::RotatedRect randomSimilarityEllipse(const UniformSimilarityParams& params, c const float s1 = rng.uniform(params.scale[0], params.scale[1]); const float x = rng.uniform(params.deltaX[0], params.deltaX[1]); const float y = rng.uniform(params.deltaY[0], params.deltaY[1]); - return cv::RotatedRect({ x, y }, { s1, s1 }, theta); + return {{ x, y }, { s1, s1 }, theta}; } // WRT specified center diff --git a/src/lib/drishti/geometry/conicPar2Cen.cpp b/src/lib/drishti/geometry/conicPar2Cen.cpp index 9e76a7f8..e7d1eccf 100644 --- a/src/lib/drishti/geometry/conicPar2Cen.cpp +++ b/src/lib/drishti/geometry/conicPar2Cen.cpp @@ -46,7 +46,7 @@ cv::RotatedRect conicPar2Cen(const cv::Vec6d& par) // ellipse = (centrex,centrey,ax,ay,orientation) if (Auu == 0 || Avv == 0) { - return cv::RotatedRect(cv::Point2f(0.f, 0.f), cv::Size2f(0.f, 0.f), 0.f); + return {cv::Point2f(0.f, 0.f), cv::Size2f(0.f, 0.f), 0.f}; } // ROTATED = [Ao Au Av Auu Avv] @@ -66,7 +66,8 @@ cv::RotatedRect conicPar2Cen(const cv::Vec6d& par) // OpenCV format: cv::Point2f center(uCentre, vCentre); cv::Size2f size(Ru * 2.0, Rv * 2.0); - return cv::RotatedRect(center, size, thetarad * 180.0 / M_PI); + const float angle = thetarad * 180.0 / M_PI; + return {center, size, angle}; } DRISHTI_GEOMETRY_END diff --git a/src/lib/drishti/geometry/ut/test-drishti-geometry.cpp b/src/lib/drishti/geometry/ut/test-drishti-geometry.cpp index 95bc98d5..760451e0 100644 --- a/src/lib/drishti/geometry/ut/test-drishti-geometry.cpp +++ b/src/lib/drishti/geometry/ut/test-drishti-geometry.cpp @@ -13,7 +13,7 @@ #include "drishti/geometry/Ellipse.h" #include "drishti/geometry/intersectConicLine.h" -TEST(Ellipse, EllipseLineIntersection2) +TEST(Ellipse, EllipseLineIntersection2) // NOLINT (TODO) { const cv::RotatedRect E({ 0.f, 0.f }, { 2.f, 1.f }, 0.f); const cv::Matx33f C = drishti::geometry::ConicSection_(E).getMatrix(); diff --git a/src/lib/drishti/graphics/GLTexture.h b/src/lib/drishti/graphics/GLTexture.h index 231fbb24..7608fe49 100644 --- a/src/lib/drishti/graphics/GLTexture.h +++ b/src/lib/drishti/graphics/GLTexture.h @@ -30,6 +30,11 @@ struct GLTexture glBindTexture(GL_TEXTURE_2D, 0); } + GLTexture(const GLTexture&) = delete; + GLTexture(GLTexture&&) = delete; + GLTexture& operator=(const GLTexture&) = delete; + GLTexture& operator=(GLTexture&&) = delete; + ~GLTexture() { glDeleteTextures(1, &texId); diff --git a/src/lib/drishti/hci/FaceFinder.h b/src/lib/drishti/hci/FaceFinder.h index 5238260e..342e4188 100644 --- a/src/lib/drishti/hci/FaceFinder.h +++ b/src/lib/drishti/hci/FaceFinder.h @@ -106,13 +106,18 @@ class FaceFinder float renderEyesWidthRatio = 0.25f; int history = DRISHTI_HCI_FACEFINDER_HISTORY; - + bool ignoreLatestFramesInMonitor = false; }; FaceFinder(FaceDetectorFactoryPtr& factory, Settings& config, void* glContext = nullptr); ~FaceFinder(); + FaceFinder(const FaceFinder&) = delete; + FaceFinder(FaceFinder&&) = delete; + FaceFinder& operator=(const FaceFinder&) = delete; + FaceFinder& operator=(FaceFinder&&) = delete; + static void tryEnablePlatformOptimizations(); virtual void initialize(); // must call at startup diff --git a/src/lib/drishti/hci/FaceFinderPainter.cpp b/src/lib/drishti/hci/FaceFinderPainter.cpp index a179d7f9..58d76e11 100644 --- a/src/lib/drishti/hci/FaceFinderPainter.cpp +++ b/src/lib/drishti/hci/FaceFinderPainter.cpp @@ -83,6 +83,11 @@ class FaceFinderPainter::Impl } ~Impl() = default; + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + std::chrono::high_resolution_clock::time_point m_tic; int m_index{}; diff --git a/src/lib/drishti/hci/FaceFinderPainter.h b/src/lib/drishti/hci/FaceFinderPainter.h index 35d3239b..3bc18794 100644 --- a/src/lib/drishti/hci/FaceFinderPainter.h +++ b/src/lib/drishti/hci/FaceFinderPainter.h @@ -44,6 +44,12 @@ class FaceFinderPainter : public FaceFinder FaceFinderPainter(FaceDetectorFactoryPtr& factory, Settings& settings, void* glContext = nullptr); ~FaceFinderPainter(); + + FaceFinderPainter(const FaceFinderPainter&) = delete; + FaceFinderPainter(FaceFinderPainter&&) = delete; + FaceFinderPainter& operator=(const FaceFinderPainter&) = delete; + FaceFinderPainter& operator=(FaceFinderPainter&&) = delete; + virtual void getOutputPixels(FrameDelegate& delegate); void init(const cv::Size& inputSize) override; void drawIris(bool flag) { m_drawIris = flag; } diff --git a/src/lib/drishti/hci/gpu/BlobFilter.h b/src/lib/drishti/hci/gpu/BlobFilter.h index d7d2c930..495212b8 100644 --- a/src/lib/drishti/hci/gpu/BlobFilter.h +++ b/src/lib/drishti/hci/gpu/BlobFilter.h @@ -28,6 +28,11 @@ class BlobFilter : public MultiPassProc BlobFilter(); ~BlobFilter() override; + BlobFilter(const BlobFilter&) = delete; + BlobFilter(BlobFilter&&) = delete; + BlobFilter& operator=(const BlobFilter&) = delete; + BlobFilter& operator=(BlobFilter&&) = delete; + ProcInterface* getInputFilter() const override; ProcInterface* getOutputFilter() const override; diff --git a/src/lib/drishti/hci/gpu/FacePainter.cpp b/src/lib/drishti/hci/gpu/FacePainter.cpp index e0d42b45..494579fc 100644 --- a/src/lib/drishti/hci/gpu/FacePainter.cpp +++ b/src/lib/drishti/hci/gpu/FacePainter.cpp @@ -153,7 +153,7 @@ FacePainter::FacePainter(int outputOrientation) m_draw = std::make_shared(); #if DRISHIT_HCI_FACEPAINTER_DO_COLOR - bool compiled = m_draw->buildFromSrc(vshaderColorVaryingSrc, fshaderColorVaryingSrc); + bool compiled = m_draw->buildFromSrc(vshaderColorVaryingSrc, fshaderColorVaryingSrc); // NOLINT (TODO) m_drawShParamAColor = m_draw->getParam(ATTR, "color"); #else bool compiled = m_draw->buildFromSrc(vshaderColorSrc, fshaderColorSrc); diff --git a/src/lib/drishti/hci/gpu/FacePainter.h b/src/lib/drishti/hci/gpu/FacePainter.h index a4ec4fa9..18c4162f 100644 --- a/src/lib/drishti/hci/gpu/FacePainter.h +++ b/src/lib/drishti/hci/gpu/FacePainter.h @@ -116,6 +116,11 @@ class FacePainter : public ogles_gpgpu::TransformProc */ ~FacePainter() override; + FacePainter(const FacePainter&) = delete; + FacePainter(FacePainter&&) = delete; + FacePainter& operator=(const FacePainter&) = delete; + FacePainter& operator=(FacePainter&&) = delete; + /** * Render a face image. */ diff --git a/src/lib/drishti/hci/gpu/GLPrinter.h b/src/lib/drishti/hci/gpu/GLPrinter.h index 279bd951..34e3aa57 100644 --- a/src/lib/drishti/hci/gpu/GLPrinter.h +++ b/src/lib/drishti/hci/gpu/GLPrinter.h @@ -24,6 +24,11 @@ class GLPrinterShader GLPrinterShader(); ~GLPrinterShader(); + GLPrinterShader(const GLPrinterShader&) = delete; + GLPrinterShader(GLPrinterShader&&) = delete; + GLPrinterShader& operator=(const GLPrinterShader&) = delete; + GLPrinterShader& operator=(GLPrinterShader&&) = delete; + static const char* getProcName() { return "GLPrinterShader"; } void begin(); diff --git a/src/lib/drishti/hci/gpu/VeraFont_16_2048.h b/src/lib/drishti/hci/gpu/VeraFont_16_2048.h index b4bd8709..8067c4dc 100644 --- a/src/lib/drishti/hci/gpu/VeraFont_16_2048.h +++ b/src/lib/drishti/hci/gpu/VeraFont_16_2048.h @@ -43,13 +43,13 @@ extern "C" { #endif -typedef struct +struct kerning_t { uint32_t codepoint; float kerning; -} kerning_t; +}; -typedef struct +struct texture_glyph_t { uint32_t codepoint; int width, height; @@ -58,9 +58,9 @@ typedef struct float s0, t0, s1, t1; size_t kerning_count; kerning_t kerning[19]; -} texture_glyph_t; +}; -typedef struct +struct texture_font_t { size_t tex_width; size_t tex_height; @@ -73,7 +73,7 @@ typedef struct float descender; size_t glyphs_count; texture_glyph_t glyphs[96]; -} texture_font_t; +}; texture_font_t Vera_16_2048 = { 2048, 2048, 1, diff --git a/src/lib/drishti/hci/ut/FaceMonitorHCITest.h b/src/lib/drishti/hci/ut/FaceMonitorHCITest.h index cd832590..e7eea7ea 100644 --- a/src/lib/drishti/hci/ut/FaceMonitorHCITest.h +++ b/src/lib/drishti/hci/ut/FaceMonitorHCITest.h @@ -20,12 +20,12 @@ class FaceMonitorHCITest : public drishti::hci::FaceMonitor int m_index = 0; - virtual Request request(const Faces& faces, const TimePoint& timeStamp, std::uint32_t tex) + Request request(const Faces& faces, const TimePoint& timeStamp, std::uint32_t tex) override { return Request{ 3, true, true }; } - virtual void grab(const std::vector& frames, bool isInitialized) + void grab(const std::vector& frames, bool isInitialized) override { m_faces = frames; m_isInitialized = isInitialized; diff --git a/src/lib/drishti/hci/ut/test-drishti-hci.cpp b/src/lib/drishti/hci/ut/test-drishti-hci.cpp index 430ffe0f..6e58b9f5 100644 --- a/src/lib/drishti/hci/ut/test-drishti-hci.cpp +++ b/src/lib/drishti/hci/ut/test-drishti-hci.cpp @@ -64,6 +64,12 @@ BEGIN_EMPTY_NAMESPACE class HCITest : public ::testing::Test { +public: + HCITest(const HCITest&) = delete; + HCITest(HCITest&&) = delete; + HCITest& operator=(const HCITest&) = delete; + HCITest& operator=(HCITest&&) = delete; + protected: bool m_hasTranspose = false; @@ -117,7 +123,7 @@ class HCITest : public ::testing::Test } // Cleanup - virtual ~HCITest() + ~HCITest() override { drishti::core::Logger::drop("test-drishti-hci"); } @@ -157,10 +163,10 @@ class HCITest : public ::testing::Test } // Called after constructor for each test - virtual void SetUp() {} + void SetUp() override {} // Called after destructor for each test - virtual void TearDown() {} + void TearDown() override {} static cv::Mat loadImage(const std::string& filename) { @@ -219,14 +225,14 @@ class HCITest : public ::testing::Test }; #if defined(DRISHTI_DO_GPU_TESTING) -TEST_F(HCITest, RunTestCPUAsync) +TEST_F(HCITest, RunTestCPUAsync) // NOLINT (TODO) { static const bool doCpu = true; static const bool doAsync = true; runTest(doCpu, doAsync); } -TEST_F(HCITest, RunTestGPUAsync) +TEST_F(HCITest, RunTestGPUAsync) // NOLINT (TODO) { static const bool doCpu = false; static const bool doAsync = true; diff --git a/src/lib/drishti/ml/ObjectDetector.h b/src/lib/drishti/ml/ObjectDetector.h index 6fd84d0b..fae1acf0 100644 --- a/src/lib/drishti/ml/ObjectDetector.h +++ b/src/lib/drishti/ml/ObjectDetector.h @@ -35,6 +35,15 @@ class ObjectDetector virtual bool getDoNonMaximaSuppression() const; virtual cv::Size getWindowSize() const = 0; + ObjectDetector() = default; + + ObjectDetector(const ObjectDetector&) = delete; + ObjectDetector(ObjectDetector&&) = delete; + ObjectDetector& operator=(const ObjectDetector&) = delete; + ObjectDetector& operator=(ObjectDetector&&) = delete; + + virtual ~ObjectDetector() = default; + protected: bool m_doNms = false; double m_detectionScorePruneRatio = 0.0; diff --git a/src/lib/drishti/ml/ObjectDetectorACF.h b/src/lib/drishti/ml/ObjectDetectorACF.h index d26eec9d..81b79044 100644 --- a/src/lib/drishti/ml/ObjectDetectorACF.h +++ b/src/lib/drishti/ml/ObjectDetectorACF.h @@ -22,25 +22,30 @@ DRISHTI_ML_NAMESPACE_BEGIN class ObjectDetectorACF : public ObjectDetector { public: - + ObjectDetectorACF(); ObjectDetectorACF(const std::string& filename); ObjectDetectorACF(std::istream& is, const std::string& hint = {}); - virtual ~ObjectDetectorACF(); - + ~ObjectDetectorACF() override; + + ObjectDetectorACF(const ObjectDetectorACF&) = delete; + ObjectDetectorACF(ObjectDetectorACF&&) = delete; + ObjectDetectorACF& operator=(const ObjectDetectorACF&) = delete; + ObjectDetectorACF& operator=(ObjectDetectorACF&&) = delete; + bool good() const; explicit operator bool() const; - + int operator()(const cv::Mat& image, std::vector& objects, std::vector* scores = nullptr) override; int operator()(const MatP& image, std::vector& objects, std::vector* scores = nullptr) override; cv::Size getWindowSize() const override; void setDoNonMaximaSuppression(bool flag) override; bool getDoNonMaximaSuppression() const override; - + acf::Detector* getDetector() const { return m_impl.get(); } protected: - + std::unique_ptr m_impl; }; diff --git a/src/lib/drishti/ml/PCA.h b/src/lib/drishti/ml/PCA.h index 32981eac..13c1e61c 100644 --- a/src/lib/drishti/ml/PCA.h +++ b/src/lib/drishti/ml/PCA.h @@ -28,6 +28,12 @@ class StandardizedPCA Standardizer(); Standardizer(int size, int type); ~Standardizer(); + + Standardizer(const Standardizer&) = delete; + Standardizer(Standardizer&&) = delete; + Standardizer& operator=(const Standardizer&) = delete; + Standardizer& operator=(Standardizer&&) = delete; + void create(int size, int type); void compute(const cv::Mat& src, const cv::Mat &columnWeights={}); cv::Mat standardize(const cv::Mat& src) const; @@ -45,6 +51,11 @@ class StandardizedPCA void compute(const cv::Mat& data, cv::Mat& projection, int maxComponents, const cv::Mat &columnWeights={}); void init(); + StandardizedPCA(const StandardizedPCA&) = delete; + StandardizedPCA(StandardizedPCA&&) = delete; + StandardizedPCA& operator=(const StandardizedPCA&) = delete; + StandardizedPCA& operator=(StandardizedPCA&&) = delete; + size_t getNumComponents() const; cv::Mat project(const cv::Mat& data, int n = 0) const; diff --git a/src/lib/drishti/ml/RTEShapeEstimatorImpl.h b/src/lib/drishti/ml/RTEShapeEstimatorImpl.h index 8fae8e69..70420510 100644 --- a/src/lib/drishti/ml/RTEShapeEstimatorImpl.h +++ b/src/lib/drishti/ml/RTEShapeEstimatorImpl.h @@ -27,6 +27,11 @@ class RegressionTreeEnsembleShapeEstimator::Impl Impl(std::istream& is, const std::string& hint = {}); ~Impl(); + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + void packPointsInShape(const std::vector& points, int ellipseCount, float* shape) const { // Copy initial chunk of 2d points diff --git a/src/lib/drishti/ml/RegressionTreeEnsembleShapeEstimator.h b/src/lib/drishti/ml/RegressionTreeEnsembleShapeEstimator.h index 6c81b2cf..2dde8a44 100644 --- a/src/lib/drishti/ml/RegressionTreeEnsembleShapeEstimator.h +++ b/src/lib/drishti/ml/RegressionTreeEnsembleShapeEstimator.h @@ -28,10 +28,15 @@ class RegressionTreeEnsembleShapeEstimator : public ShapeEstimator class Impl; RegressionTreeEnsembleShapeEstimator(); - RegressionTreeEnsembleShapeEstimator(const std::string& filename); - RegressionTreeEnsembleShapeEstimator(std::istream& is, const std::string& hint = {}); + explicit RegressionTreeEnsembleShapeEstimator(const std::string& filename); + explicit RegressionTreeEnsembleShapeEstimator(std::istream& is, const std::string& hint = {}); ~RegressionTreeEnsembleShapeEstimator() override; + RegressionTreeEnsembleShapeEstimator(const RegressionTreeEnsembleShapeEstimator&) = delete; + RegressionTreeEnsembleShapeEstimator(RegressionTreeEnsembleShapeEstimator&&) = delete; + RegressionTreeEnsembleShapeEstimator& operator=(const RegressionTreeEnsembleShapeEstimator&) = delete; + RegressionTreeEnsembleShapeEstimator& operator=(RegressionTreeEnsembleShapeEstimator&&) = delete; + void setStreamLogger(std::shared_ptr& logger) override; int operator()(const cv::Mat& I, const cv::Mat& M, Point2fVec& points, BoolVec& mask) const override; int operator()(const cv::Mat& I, Point2fVec& points, BoolVec& mask) const override; diff --git a/src/lib/drishti/ml/ShapeEstimator.h b/src/lib/drishti/ml/ShapeEstimator.h index a010b0cb..0f35b174 100644 --- a/src/lib/drishti/ml/ShapeEstimator.h +++ b/src/lib/drishti/ml/ShapeEstimator.h @@ -30,6 +30,13 @@ class ShapeEstimator using BoolVec = std::vector; using Point2fVec = std::vector; + ShapeEstimator() = default; + + ShapeEstimator(const ShapeEstimator&) = delete; + ShapeEstimator(ShapeEstimator&&) = delete; + ShapeEstimator& operator=(const ShapeEstimator&) = delete; + ShapeEstimator& operator=(ShapeEstimator&&) = delete; + virtual ~ShapeEstimator(); virtual void setStreamLogger(std::shared_ptr& logger) diff --git a/src/lib/drishti/ml/XGBooster.h b/src/lib/drishti/ml/XGBooster.h index 6efc46da..34f1f9a0 100644 --- a/src/lib/drishti/ml/XGBooster.h +++ b/src/lib/drishti/ml/XGBooster.h @@ -46,6 +46,11 @@ class XGBooster float operator()(const std::vector& features); void train(const MatrixType& features, const std::vector& values, const MatrixType& mask = {}); + XGBooster(const XGBooster&) = delete; + XGBooster(XGBooster&&) = delete; + XGBooster& operator=(const XGBooster&) = delete; + XGBooster& operator=(XGBooster&&) = delete; + void read(const std::string& filename); void write(const std::string& filename) const; diff --git a/src/lib/drishti/ml/XGBoosterImpl.h b/src/lib/drishti/ml/XGBoosterImpl.h index 77caf027..d9bff71d 100644 --- a/src/lib/drishti/ml/XGBoosterImpl.h +++ b/src/lib/drishti/ml/XGBoosterImpl.h @@ -41,12 +41,17 @@ class XGBooster::Impl init(); } - Impl(const Recipe& recipe) + explicit Impl(const Recipe& recipe) : m_recipe(recipe) { init(); } + Impl(const Impl&) = delete; + Impl(Impl&&) = delete; + Impl& operator=(const Impl&) = delete; + Impl& operator=(Impl&&) = delete; + ~Impl(); void init() diff --git a/src/lib/drishti/ml/shape_predictor.h b/src/lib/drishti/ml/shape_predictor.h index 62c90cd3..fd95ed61 100644 --- a/src/lib/drishti/ml/shape_predictor.h +++ b/src/lib/drishti/ml/shape_predictor.h @@ -95,8 +95,8 @@ inline dlib::point dlib_point(const cv::Point& p) return dlib::point(p.x, p.y); } -typedef dlib::matrix fshape; -typedef dlib::vector fpoint; +using fshape = dlib::matrix; +using fpoint = dlib::vector; using PointVecf = std::vector; using PointVecVecf = std::vector; @@ -686,6 +686,11 @@ class shape_predictor shape_predictor() = default; ~shape_predictor() = default; + shape_predictor(const shape_predictor&) = delete; + shape_predictor(shape_predictor&&) = delete; + shape_predictor& operator=(const shape_predictor&) = delete; + shape_predictor& operator=(shape_predictor&&) = delete; + shape_predictor( fshape initial_shape_, std::vector> forests_, @@ -1059,7 +1064,7 @@ void deserialize(drishti::ml::shape_predictor& item, std::istream& in); DRISHTI_ML_NAMESPACE_END using RTType = drishti::ml::impl::regression_tree; -typedef dlib::vector Vec2Type; +using Vec2Type = dlib::vector; #if DRISHTI_DLIB_DO_HALF struct PointHalf diff --git a/src/lib/drishti/ml/ut/test-drishti-ml.cpp b/src/lib/drishti/ml/ut/test-drishti-ml.cpp index 7a80039a..d34baf12 100644 --- a/src/lib/drishti/ml/ut/test-drishti-ml.cpp +++ b/src/lib/drishti/ml/ut/test-drishti-ml.cpp @@ -18,14 +18,14 @@ #include "drishti/core/drishti_cereal_pba.h" #include "drishti/core/drishti_cv_cereal.h" -TEST(XGBooster, XGBoosterInit) +TEST(XGBooster, XGBoosterInit) // NOLINT (TODO) { // Run simple function fit w/ full (non-lean) builds: drishti::ml::XGBooster booster; ASSERT_EQ(true, true); } -TEST(StandardizedPCA, gemm_transpose_continuous) +TEST(StandardizedPCA, gemm_transpose_continuous) // NOLINT (TODO) { cv::Mat A, Bt, C; @@ -45,14 +45,14 @@ TEST(StandardizedPCA, gemm_transpose_continuous) ASSERT_EQ(C.rows, A.rows); ASSERT_EQ(C.cols, Bt.rows); - for (auto iter = C.begin(); iter != C.end(); iter++) + for (auto iter = C.begin(); iter != C.end(); iter++) // NOLINT (TODO) { EXPECT_FLOAT_EQ(*iter, float(dim)); } } } -TEST(StandardizedPCA, gemm_transpose_non_continuous) +TEST(StandardizedPCA, gemm_transpose_non_continuous) // NOLINT (TODO) { cv::Mat A, Bt1, Bt, C; @@ -73,7 +73,7 @@ TEST(StandardizedPCA, gemm_transpose_non_continuous) ASSERT_EQ(C.rows, A.rows); ASSERT_EQ(C.cols, Bt.rows); - for (auto iter = C.begin(); iter != C.end(); iter++) + for (auto iter = C.begin(); iter != C.end(); iter++) // NOLINT (TODO) { EXPECT_FLOAT_EQ(*iter, float(dim)); } diff --git a/src/lib/drishti/rcpr/CPR.cpp b/src/lib/drishti/rcpr/CPR.cpp index 25f57c20..42daf7a7 100644 --- a/src/lib/drishti/rcpr/CPR.cpp +++ b/src/lib/drishti/rcpr/CPR.cpp @@ -89,7 +89,7 @@ void CPR::CprPrm::FtrPrm::merge(const CPR::CprPrm::FtrPrm& opts, int checkExtra) static cv::RotatedRect pointsToEllipse(const std::vector& points) { - return cv::RotatedRect({ points[0].x, points[1].x }, { points[2].x, points[3].x }, points[4].x); + return { { points[0].x, points[1].x }, { points[2].x, points[3].x }, points[4].x }; } static Vector1d pointsToPhi(const std::vector& points) diff --git a/src/lib/drishti/rcpr/CPR.h b/src/lib/drishti/rcpr/CPR.h index 528146c3..84fdb03a 100644 --- a/src/lib/drishti/rcpr/CPR.h +++ b/src/lib/drishti/rcpr/CPR.h @@ -52,7 +52,7 @@ inline int PointVecSize(const PointVec& v) return int(v.size()); } -typedef cv::Matx Matx33Real; +using Matx33Real = cv::Matx; using Vector1d = std::vector; using ImageVec = std::vector; using IntVec = std::vector; @@ -68,9 +68,13 @@ class CPR : public drishti::ml::ShapeEstimator CPR(); CPR(const CPR& src); + CPR(CPR&&) = delete; + CPR& operator=(const CPR&) = delete; + CPR& operator=(CPR&&) = delete; + #if !DRISHTI_CPR_DO_LEAN - CPR(const std::string& filename); - CPR(const char* filename); + explicit CPR(const std::string& filename); + explicit CPR(const char* filename); #endif ~CPR() override; diff --git a/src/lib/drishti/rcpr/Vector1d.h b/src/lib/drishti/rcpr/Vector1d.h index 6986a12f..22eb53be 100644 --- a/src/lib/drishti/rcpr/Vector1d.h +++ b/src/lib/drishti/rcpr/Vector1d.h @@ -17,7 +17,7 @@ DRISHTI_RCPR_NAMESPACE_BEGIN inline cv::RotatedRect operator*(const cv::RotatedRect& e, float scale) { - return cv::RotatedRect(e.center * scale, e.size * scale, e.angle); + return { e.center * scale, e.size * scale, e.angle }; } // diff --git a/src/lib/drishti/rcpr/poseGt.cpp b/src/lib/drishti/rcpr/poseGt.cpp index 57396d7d..ea439d61 100644 --- a/src/lib/drishti/rcpr/poseGt.cpp +++ b/src/lib/drishti/rcpr/poseGt.cpp @@ -247,7 +247,7 @@ int ftrsGen(const CPR::Model& model, const CPR::CprPrm::FtrPrm& ftrPrmIn, FtrDat cv::RNG rng; while (points.size() < (F1 * 4)) { - rng.state = rand(); + rng.state = rand(); // NOLINT (TODO) cv::Point2f p(rng.uniform(-1.0, +1.0), rng.uniform(-1.0, +1.0)); if (cv::norm(p) < 1.0) {