Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for OAK-D Pro #287

Merged
merged 12 commits into from
Feb 23, 2022
Merged

Support for OAK-D Pro #287

merged 12 commits into from
Feb 23, 2022

Conversation

alex-luxonis
Copy link
Contributor

@alex-luxonis alex-luxonis commented Nov 30, 2021

Edit: simplified API added now:

    /**
     * Sets the brightness of the IR Laser Dot Projector. 
     * Limits: up to 765mA at 30% duty cycle, up to 1200mA at 6% duty cycle.
     * The duty cycle is controlled by `left` camera STROBE, aligned to start of exposure.
     * The emitter is turned off by default
     *
     * @param mA Current in mA that will determine brightness, 0 or negative to turn off
     * @param mask Optional mask to modify only Left (0x1) or Right (0x2) sides on OAK-D-Pro-W-DEV
     * @returns True on success, false if not found or other failure
     */
    bool setIrLaserDotProjectorBrightness(float mA, int mask = -1);

    /**
     * Sets the brightness of the IR Flood Light. Limits: up to 1500mA at 30% duty cycle.
     * The duty cycle is controlled by the `left` camera STROBE, aligned to start of exposure.
     * If the dot projector is also enabled, its lower duty cycle limits take precedence.
     * The emitter is turned off by default
     *
     * @param mA Current in mA that will determine brightness, 0 or negative to turn off
     * @param mask Optional mask to modify only Left (0x1) or Right (0x2) sides on OAK-D-Pro-W-DEV
     * @returns True on success, false if not found or other failure
     */
    bool setIrFloodLightBrightness(float mA, int mask = -1);

    /**
     * Retrieves detected IR laser/LED drivers.
     *
     * @returns Vector of tuples containing: driver name, I2C bus, I2C address.
     * For OAK-D-Pro it should be `[{"LM3644", 2, 0x63}]`
     */
    std::vector<std::tuple<std::string, int, int>> getIrDrivers();

Example on how the duty-cycle limitation is applied:

30 FPS, 30% duty cycle --> max 10ms from 33.3ms frame-time

frame-time |---------33.3ms---------|---------33.3ms---------|---------33.3ms---------|
exposure          <------20ms------>                <--10ms->                  <-8ms->
          _        _________                         ________                   ______
STROBE     |______|   10ms  |_______________________|  10ms  |_________________| 8ms  |

@artificiel
Copy link

artificiel commented Feb 3, 2022

hello! what is the status for OAK-D PRO support in C++? i went ahead on branch oak-d-pro_develop and fearlessly modified the depth_preview example.cpp with:

device.irWriteReg(0x2, 0x1);
device.irWriteReg(0x3, 0x0);
// etc.. as per the python example

... and it compiles and runs but it's not clear what the registers do, and hard to know what toggles are available. we have an OAK-D (non-pro) that works fine so we can compare/confirm with the fresh OAK-D PRO.

running on Apple M1 Silicon, getting the python stuff to work natively is a big pain (and we do not want to run rosetta and/or dual homebrew setups); and anyhow our target language is C++ and compiling and linking the libs into our software is quick and seamless (works superb with the OAK-D). so we'd like to be able to confirm our understanding of the PRO features without needing to run python.

a C++ example of the different registers would be great!

@alex-luxonis
Copy link
Contributor Author

I should have mentioned here as well, a simpler API was added on the branch multi_cam_support in c4b5cc7
(will add it on this PR too)

The projectors are disabled by default, configured to align with camera exposure (by strobe), and this API is available:

    /**
     * Sets the brightness of the IR Laser Dot Projector. 
     * Theoretical maximum 1500mA, but recommended to not exceed 765mA.
     *
     * @param mA Current in mA that will determine brightness, 0 or negative to turn off
     * @param mask Optional mask to modify only Left (0x1) or Right (0x2) sides on OAK-D-Pro-W-DEV
     */
    void setIrLaserDotProjectorBrightness(float mA, int mask = -1);

    /**
     * Sets the brightness of the IR Flood Light. Maximum 1500mA.
     *
     * @param mA Current in mA that will determine brightness, 0 or negative to turn off
     * @param mask Optional mask to modify only Left (0x1) or Right (0x2) sides on OAK-D-Pro-W-DEV
     */
    void setIrFloodLightBrightness(float mA, int mask = -1);

Example for configuring:

device.setIrLaserDotProjectorBrightness(100);  // mA
device.setIrFloodLightBrightness(250);  // mA

@artificiel
Copy link

artificiel commented Feb 4, 2022

ah! that's nice. however checking out multi_cam_support does not compile here: (error pattern repeated a couple of times):

[  8%] Linking CXX static library libutility.a
[In file included from /Users/*/source_control/pro/depthai-core/src/pipeline/Pipeline.cpp:1:
In file included from /Users/*/source_control/pro/depthai-core/include/depthai/pipeline/Pipeline.hpp:13:
In file included from /Users/*/source_control/pro/depthai-core/include/depthai/device/Device.hpp:14:
In file included from /Users/*/source_control/pro/depthai-core/include/depthai/device/DeviceBase.hpp:17:
/Users/*/source_control/pro/depthai-core/include/depthai/common/CameraBoardSocket.hpp:22:38: error: no member named 'CAM_D' in 'dai::CameraBoardSocket'
        case dai::CameraBoardSocket::CAM_D:
             ~~~~~~~~~~~~~~~~~~~~~~~~^
/Users/*/source_control/pro/depthai-core/include/depthai/common/CameraBoardSocket.hpp:25:38: error: no member named 'CAM_E' in 'dai::CameraBoardSocket'
        case dai::CameraBoardSocket::CAM_E:
             ~~~~~~~~~~~~~~~~~~~~~~~~^
/Users/*/source_control/pro/depthai-core/include/depthai/common/CameraBoardSocket.hpp:28:38: error: no member named 'CAM_F' in 'dai::CameraBoardSocket'
        case dai::CameraBoardSocket::CAM_F:
             ~~~~~~~~~~~~~~~~~~~~~~~~^
/Users/*/source_control/pro/depthai-core/include/depthai/common/CameraBoardSocket.hpp:31:38: error: no member named 'CAM_G' in 'dai::CameraBoardSocket'
        case dai::CameraBoardSocket::CAM_G:
             ~~~~~~~~~~~~~~~~~~~~~~~~^
/Users/*/source_control/pro/depthai-core/include/depthai/common/CameraBoardSocket.hpp:34:38: error: no member named 'CAM_H' in 'dai::CameraBoardSocket'
        case dai::CameraBoardSocket::CAM_H:
             ~~~~~~~~~~~~~~~~~~~~~~~~^
In file included from /Users/*/source_control/pro/depthai-core/src/pipeline/Pipeline.cpp:1:
In file included from /Users/*/source_control/pro/depthai-core/include/depthai/pipeline/Pipeline.hpp:13:
In file included from /Users/*/source_control/pro/depthai-core/include/depthai/device/Device.hpp:14:
/Users/*/source_control/pro/depthai-core/include/depthai/device/DeviceBase.hpp:26:10: fatal error: 'depthai-shared/common/CameraProperties.hpp' file not found
#include "depthai-shared/common/CameraProperties.hpp"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[  9%] Building CXX object CMakeFiles/depthai-core.dir/src/pipeline/Node.cpp.o
6 errors generated.

@alex-luxonis
Copy link
Contributor Author

@artificiel Likely the depthai-shared submodule was not updated.
Could you do a git pull (just in case, to be on the latest), then:

git submodule update --recursive --init --progress

@artificiel
Copy link

ah the submodule... now it works, thanks!

@alex-luxonis alex-luxonis merged commit 4d4f5bc into develop Feb 23, 2022
@alex-luxonis alex-luxonis deleted the oak-d-pro_develop branch February 23, 2022 15:58
@PeterQFR
Copy link

PeterQFR commented Mar 13, 2022

@alex-luxonis Is there support for for the IR settings as per the table luxonis/depthai-hardware#114?
such as
5. IR laser on for even frames, IR LED on for odd frames

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.

None yet

3 participants