Skip to content

Commit

Permalink
Anti-aliasing element for <camera><image> (#909)
Browse files Browse the repository at this point in the history
Signed-off-by: William Lew <WilliamMilesLew@gmail.com>
  • Loading branch information
WilliamLewww authored Mar 29, 2022
1 parent 41ad073 commit 72b77c2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/sdf/Camera.hh
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ namespace sdf
/// \param[in] _fmt The pixel format string.
public: void SetPixelFormatStr(const std::string &_fmt);

/// \brief Get the anti-aliasing value.
/// \return The anti-aliasing value.
public: uint32_t AntiAliasingValue() const;

/// \brief Set the anti-aliasing value.
/// \param[in] _antiAliasingValue The anti-aliasing value.
public: void SetAntiAliasingValue(uint32_t _antiAliasingValue);

/// \brief Get the near clip distance for the depth camera.
/// \return The near clip depth distance.
public: double DepthNearClip() const;
Expand Down
3 changes: 3 additions & 0 deletions sdf/1.7/camera.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<element name="format" type="string" default="R8G8B8" required="0">
<description>(L8|R8G8B8|B8G8R8|BAYER_RGGB8|BAYER_BGGR8|BAYER_GBRG8|BAYER_GRBG8)</description>
</element>
<element name="anti_aliasing" type="int" default="4" required="0">
<description>Value used for anti-aliasing</description>
</element>
</element> <!-- End Image -->

<element name="clip" required="1">
Expand Down
19 changes: 19 additions & 0 deletions src/Camera.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class sdf::CameraPrivate
/// \brief Image format.
public: PixelFormatType pixelFormat{PixelFormatType::RGB_INT8};

/// \brief Anti-aliasing value.
public: uint32_t antiAliasingValue{4};

/// \brief Near clip distance.
public: double nearClip{0.1};

Expand Down Expand Up @@ -270,6 +273,10 @@ Errors Camera::Load(ElementPtr _sdf)
errors.push_back({ErrorCode::ELEMENT_INVALID,
"Camera sensor <image><format> has invalid value of " + format});
}

this->dataPtr->antiAliasingValue =
elem->Get<uint32_t>("anti_aliasing",
this->dataPtr->antiAliasingValue).first;
}
else
{
Expand Down Expand Up @@ -467,6 +474,18 @@ void Camera::SetPixelFormatStr(const std::string &_fmt)
this->dataPtr->pixelFormat = ConvertPixelFormat(_fmt);
}

//////////////////////////////////////////////////
uint32_t Camera::AntiAliasingValue() const
{
return this->dataPtr->antiAliasingValue;
}

//////////////////////////////////////////////////
void Camera::SetAntiAliasingValue(uint32_t _antiAliasingValue)
{
this->dataPtr->antiAliasingValue = _antiAliasingValue;
}

//////////////////////////////////////////////////
double Camera::DepthNearClip() const
{
Expand Down
4 changes: 4 additions & 0 deletions src/Camera_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ TEST(DOMCamera, Construction)
cam.SetPixelFormat(sdf::PixelFormatType::L_INT8);
EXPECT_EQ(sdf::PixelFormatType::L_INT8 , cam.PixelFormat());

EXPECT_EQ(4u, cam.AntiAliasingValue());
cam.SetAntiAliasingValue(8);
EXPECT_EQ(8u, cam.AntiAliasingValue());

EXPECT_DOUBLE_EQ(0.1, cam.DepthNearClip());
EXPECT_FALSE(cam.HasDepthNearClip());
cam.SetDepthNearClip(0.2);
Expand Down

0 comments on commit 72b77c2

Please sign in to comment.