la_mojo: make the Darknet (YOLO filter) build and link #17

Merged
ClaudeAI merged 1 commits from fix/la-mojo-darknet into master 2 hours ago
ClaudeAI commented 2 hours ago
Collaborator

Summary

Makes the Darknet-based YOLO filter from 65b87bb compile and link. The header facts come from upstream Darknet (hank-ai/darknet, src-lib/darknet.h and src-lib/CMakeLists.txt).

Why it did not work

  1. The functions used are hidden by default. Since Darknet V3, load_network(), load_network_custom() and free_network_ptr() are only declared when DARKNET_INCLUDE_ORIGINAL_API is defined before darknet.h. Otherwise all three give '...' was not declared in this scope.
  2. Wrong pointer type. m_pNET was declared as DarknetNetworkPtr *, i.e. void **, but DarknetNetworkPtr is already typedef void*. The result: invalid conversion from 'DarknetNetworkPtr' {aka 'void*'} to 'void**'.
  3. Wrong include path. Darknet installs its header as <prefix>/include/darknet.h, not include/darknet/darknet.h.
  4. The library was never linked in the build actually used. -ldarknet was only in Release86, while ./build uses Debug86.

Problems 1 and 2 were reproduced by compiling the original file against the upstream declarations.

Changes

  • kernelEventFilterYOLO.h:
    • defines DARKNET_INCLUDE_ORIGINAL_API;
    • includes <darknet.h>, falls back to <darknet/darknet.h>, and stops with a clear #error if neither exists;
    • m_pNET is now a plain DarknetNetworkPtr.
  • makefile and la_mojo.vpj: -ldarknet is added to Debug86 and Debug. It is in the .vpj too, so a SlickEdit regeneration keeps it. Release and LRF_Proxy_ONLY do not link OpenCV or FFmpeg either, so they cannot build la_mojo at the moment anyway; they are left unchanged.
  • kernelEventFilterYOLO::initFilter():
    • loads the settings first with validate(). Before, m_sYOLOFilterData was still zero, so fileExist("") failed and the filter could never start;
    • logs why it fails, frees a previously loaded network, and logs the network dimensions;
    • the messages are kept short because LOG_ERROR formats into a 256-byte buffer.
  • Destructor: stops the thread before freeing the network.

Testing

Darknet is not available in the build container, so the tests used a stand-in darknet.h with the exact upstream declarations and a stand-in libdarknet.so:

  • kernelEventFilterYOLO.cpp compiles with no warnings (-Wall -W -pedantic);
  • a full Debug86 make -k compiles every file except the three that need live555, which cannot be installed in the container;
  • the link test leaves no unresolved Darknet symbols.

On the build machine, Darknet (libdarknet.so + darknet.h) must be installed.

Still missing before YOLO actually runs

These are not part of this PR:

  • No settings source: no data binder implements getYOLOFilterData(); the base class returns NULL. There is no target_filter_yolo table either (the Bubble filter uses target_filter_bubble).
  • The filter is never created: the TF_YOLO_FILTER case in mojoKernel is still empty.

Generated with Claude Code

https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16

## Summary Makes the Darknet-based YOLO filter from 65b87bb compile and link. The header facts come from upstream Darknet ([hank-ai/darknet](https://github.com/hank-ai/darknet), `src-lib/darknet.h` and `src-lib/CMakeLists.txt`). ## Why it did not work 1. **The functions used are hidden by default.** Since Darknet V3, `load_network()`, `load_network_custom()` and `free_network_ptr()` are only declared when `DARKNET_INCLUDE_ORIGINAL_API` is defined before `darknet.h`. Otherwise all three give `'...' was not declared in this scope`. 2. **Wrong pointer type.** `m_pNET` was declared as `DarknetNetworkPtr *`, i.e. `void **`, but `DarknetNetworkPtr` is already `typedef void*`. The result: `invalid conversion from 'DarknetNetworkPtr' {aka 'void*'} to 'void**'`. 3. **Wrong include path.** Darknet installs its header as `<prefix>/include/darknet.h`, not `include/darknet/darknet.h`. 4. **The library was never linked in the build actually used.** `-ldarknet` was only in Release86, while `./build` uses Debug86. Problems 1 and 2 were reproduced by compiling the original file against the upstream declarations. ## Changes - **`kernelEventFilterYOLO.h`:** - defines `DARKNET_INCLUDE_ORIGINAL_API`; - includes `<darknet.h>`, falls back to `<darknet/darknet.h>`, and stops with a clear `#error` if neither exists; - `m_pNET` is now a plain `DarknetNetworkPtr`. - **`makefile` and `la_mojo.vpj`:** `-ldarknet` is added to Debug86 and Debug. It is in the `.vpj` too, so a SlickEdit regeneration keeps it. Release and LRF_Proxy_ONLY do not link OpenCV or FFmpeg either, so they cannot build la_mojo at the moment anyway; they are left unchanged. - **`kernelEventFilterYOLO::initFilter()`:** - loads the settings first with `validate()`. Before, `m_sYOLOFilterData` was still zero, so `fileExist("")` failed and the filter could never start; - logs why it fails, frees a previously loaded network, and logs the network dimensions; - the messages are kept short because `LOG_ERROR` formats into a 256-byte buffer. - **Destructor:** stops the thread before freeing the network. ## Testing Darknet is not available in the build container, so the tests used a stand-in `darknet.h` with the exact upstream declarations and a stand-in `libdarknet.so`: - `kernelEventFilterYOLO.cpp` compiles with no warnings (`-Wall -W -pedantic`); - a full Debug86 `make -k` compiles every file except the three that need live555, which cannot be installed in the container; - the link test leaves no unresolved Darknet symbols. **On the build machine,** Darknet (`libdarknet.so` + `darknet.h`) must be installed. ## Still missing before YOLO actually runs These are not part of this PR: - **No settings source:** no data binder implements `getYOLOFilterData()`; the base class returns NULL. There is no `target_filter_yolo` table either (the Bubble filter uses `target_filter_bubble`). - **The filter is never created:** the `TF_YOLO_FILTER` case in `mojoKernel` is still empty. Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
ClaudeAI added 1 commit 2 hours ago
9ea7055649
la_mojo: make the Darknet (YOLO filter) build and link
ClaudeAI merged commit 3b9a5fa839 into master 2 hours ago
The pull request has been merged as 3b9a5fa839.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.