Program Listing for File Camera.hpp

Return to documentation for file (include/depthai/pipeline/node/Camera.hpp)

#pragma once

#include <depthai/pipeline/datatype/CameraControl.hpp>

#include "depthai/pipeline/Node.hpp"
#include "depthai/pipeline/datatype/ImgFrame.hpp"
#include "depthai/utility/span.hpp"

// shared
#include <depthai-shared/properties/CameraProperties.hpp>

namespace dai {
namespace node {

class Camera : public NodeCRTP<Node, Camera, CameraProperties> {
   public:
    constexpr static const char* NAME = "Camera";

   protected:
    Properties& getProperties();

   private:
    std::shared_ptr<RawCameraControl> rawControl;

   public:
    Camera(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId);
    Camera(const std::shared_ptr<PipelineImpl>& par, int64_t nodeId, std::unique_ptr<Properties> props);

    static int getScaledSize(int input, int num, int denom);

    CameraControl initialControl;

    Input inputConfig{*this, "inputConfig", Input::Type::SReceiver, false, 8, {{DatatypeEnum::ImageManipConfig, false}}};

    Input inputControl{*this, "inputControl", Input::Type::SReceiver, true, 8, {{DatatypeEnum::CameraControl, false}}};

    Output video{*this, "video", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};

    Output preview{*this, "preview", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};

    Output still{*this, "still", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};

    Output isp{*this, "isp", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};

    Output raw{*this, "raw", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};

    Output frameEvent{*this, "frameEvent", Output::Type::MSender, {{DatatypeEnum::ImgFrame, false}}};

    // /**
    //  * Input for mocking 'isp' functionality.
    //  *
    //  * Default queue is non-blocking with size 8
    //  */
    // Input mockIsp{*this, "mockIsp", Input::Type::SReceiver, false, 8, {{DatatypeEnum::ImgFrame, false}}};

    void setBoardSocket(CameraBoardSocket boardSocket);

    CameraBoardSocket getBoardSocket() const;

    void setCamera(std::string name);

    std::string getCamera() const;

    void setImageOrientation(CameraImageOrientation imageOrientation);

    CameraImageOrientation getImageOrientation() const;

    // TODO(themarpe) - add back
    // /// Set image type of preview output images.
    // void setPreviewType(ImgFrame::Type type);
    // /// Get image type of preview output frames.
    // ImgFrame::Type getPreviewType() const;
    // /// Set image type of video output images. Supported AUTO, GRAY, YUV420 and NV12.
    // void setVideoType(ImgFrame::Type type);
    // /// Get image type of video output frames. Supported AUTO, GRAY, YUV420 and NV12.
    // ImgFrame::Type getVideoType() const;

    void setSize(std::tuple<int, int> size);
    void setSize(int width, int height);

    void setPreviewSize(int width, int height);

    void setPreviewSize(std::tuple<int, int> size);

    void setVideoSize(int width, int height);

    void setVideoSize(std::tuple<int, int> size);

    void setStillSize(int width, int height);

    void setStillSize(std::tuple<int, int> size);

    // /**
    //  * Set 'isp' output scaling (numerator/denominator), preserving the aspect ratio.
    //  * The fraction numerator/denominator is simplified first to a irreducible form,
    //  * then a set of hardware scaler constraints applies:
    //  * max numerator = 16, max denominator = 63
    //  */
    // void setIspScale(int numerator, int denominator);

    // /// Set 'isp' output scaling, as a tuple <numerator, denominator>
    // void setIspScale(std::tuple<int, int> scale);

    // /**
    //  * Set 'isp' output scaling, per each direction. If the horizontal scaling factor
    //  * (horizNum/horizDen) is different than the vertical scaling factor
    //  * (vertNum/vertDen), a distorted (stretched or squished) image is generated
    //  */
    // void setIspScale(int horizNum, int horizDenom, int vertNum, int vertDenom);

    // /// Set 'isp' output scaling, per each direction, as <numerator, denominator> tuples
    // void setIspScale(std::tuple<int, int> horizScale, std::tuple<int, int> vertScale);

    void setFps(float fps);

    [[deprecated("setIsp3aFps is unstable")]] void setIsp3aFps(int isp3aFps);

    float getFps() const;

    std::tuple<int, int> getPreviewSize() const;
    int getPreviewWidth() const;
    int getPreviewHeight() const;

    std::tuple<int, int> getVideoSize() const;
    int getVideoWidth() const;
    int getVideoHeight() const;

    std::tuple<int, int> getStillSize() const;
    int getStillWidth() const;
    int getStillHeight() const;

    std::tuple<int, int> getSize() const;
    int getWidth() const;
    int getHeight() const;

    // /// Get 'isp' output resolution as size, after scaling
    // std::tuple<int, int> getIspSize() const;
    // /// Get 'isp' output width
    // int getIspWidth() const;
    // /// Get 'isp' output height
    // int getIspHeight() const;

    // /**
    //  * Specify sensor center crop.
    //  * Resolution size / video size
    //  */
    // void sensorCenterCrop();

    // /**
    //  * Specifies sensor crop rectangle
    //  * @param x Top left X coordinate
    //  * @param y Top left Y coordinate
    //  */
    // void setSensorCrop(float x, float y);

    // /**
    //  * @returns Sensor top left crop coordinates
    //  */
    // std::tuple<float, float> getSensorCrop() const;
    // /// Get sensor top left x crop coordinate
    // float getSensorCropX() const;
    // /// Get sensor top left y crop coordinate
    // float getSensorCropY() const;

    // /**
    //  * Specifies whether preview output should preserve aspect ratio,
    //  * after downscaling from video size or not.
    //  *
    //  * @param keep If true, a larger crop region will be considered to still be able to
    //  * create the final image in the specified aspect ratio. Otherwise video size is resized to fit preview size
    //  */
    // void setPreviewKeepAspectRatio(bool keep);

    // /**
    //  * @see setPreviewKeepAspectRatio
    //  * @returns Preview keep aspect ratio option
    //  */
    // bool getPreviewKeepAspectRatio();

    // /// Get number of frames in preview pool
    // int getPreviewNumFramesPool();
    // /// Get number of frames in video pool
    // int getVideoNumFramesPool();
    // /// Get number of frames in still pool
    // int getStillNumFramesPool();
    // /// Get number of frames in raw pool
    // int getRawNumFramesPool();
    // /// Get number of frames in isp pool
    // int getIspNumFramesPool();

    void setMeshSource(Properties::WarpMeshSource source);
    Properties::WarpMeshSource getMeshSource() const;

    void loadMeshFile(const dai::Path& warpMesh);

    void loadMeshData(span<const std::uint8_t> warpMesh);

    void setMeshStep(int width, int height);
    std::tuple<int, int> getMeshStep() const;

    void setCalibrationAlpha(float alpha);
    tl::optional<float> getCalibrationAlpha() const;

    void setRawOutputPacked(bool packed);
};

}  // namespace node
}  // namespace dai