Skip to content

Fix non-OpenCV build: guard TrackedObjectBBox usage, move EffectMask test - #1087

Open
Chzrz89 wants to merge 1 commit into
OpenShot:developfrom
Chzrz89:fix/effectbase-opencv-link
Open

Fix non-OpenCV build: guard TrackedObjectBBox usage, move EffectMask test#1087
Chzrz89 wants to merge 1 commit into
OpenShot:developfrom
Chzrz89:fix/effectbase-opencv-link

Conversation

@Chzrz89

@Chzrz89 Chzrz89 commented Aug 26, 2026

Copy link
Copy Markdown

Summary

Two small fixes so the project builds with ENABLE_OPENCV=OFF (currently it fails to link):

1. EffectBase::TrackedObjectMask() linker errors

The method dereferences TrackedObjectBBox::Contains() / GetBox() unconditionally, but TrackedObjectBBox.cpp is only compiled when OpenCV is enabled (it lives in OPENSHOT_CV_SOURCES). Every non-OpenCV build dies with:

undefined reference to `openshot::TrackedObjectBBox::Contains(long long) const'
undefined reference to `openshot::TrackedObjectBBox::GetBox(long long)'

Guarded the body with #ifndef USE_OPENCV, returning an empty mask. This is semantically correct: bounding boxes are only ever produced by the OpenCV-based trackers, so with OpenCV absent there is nothing to draw. Behavior for OpenCV builds is unchanged.

2. tests/EffectMask.cpp unconditionally registered

The test includes <opencv2/dnn.hpp> but was listed in the always-built OPENSHOT_TESTS instead of the existing if($CACHE{HAVE_OPENCV}) block, failing test-suite compilation without OpenCV. Moved it under the guard, losing no coverage (it could never build without OpenCV).

Testing

  • Windows/MSYS2 (MinGW-w64 GCC 16.2.0): full build including unit tests and openshot-player example passes with ENABLE_OPENCV=OFF
  • OpenCV builds take the unchanged code path

…test

Two issues break builds with ENABLE_OPENCV=OFF:

1. EffectBase::TrackedObjectMask() dereferences TrackedObjectBBox
   methods unconditionally, but TrackedObjectBBox.cpp is only compiled
   when OpenCV is enabled (it is in OPENSHOT_CV_SOURCES). This causes
   undefined-reference linker errors on every non-OpenCV build.

   Guard the method body with #ifndef USE_OPENCV and return an empty
   mask: bounding boxes are only ever produced by OpenCV-based
   trackers, so there is nothing to draw when OpenCV is absent.
   Behavior is unchanged for OpenCV builds.

2. tests/EffectMask.cpp includes <opencv2/dnn.hpp> unconditionally,
   but was registered in OPENSHOT_TESTS outside the HAVE_OPENCV block,
   failing compilation of the test suite without OpenCV. Move it into
   the existing if($CACHE{HAVE_OPENCV}) list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant