Skip to content

Commit

Permalink
Tiny code improvements
Browse files Browse the repository at this point in the history
Summary:
- Added asserts
- Removed some variable updates, because the value is not used below anymore.

Reviewed By: enpe

Differential Revision: D64195174

fbshipit-source-id: bc17a7eccd2f6e118aebf3cd2736bc80677e34bf
  • Loading branch information
janherling authored and facebook-github-bot committed Oct 10, 2024
1 parent ecda6c3 commit cbbcf39
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions impl/ocean/cv/segmentation/FrameFilterBlur.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ bool FrameFilterBlur::blurMaskRegions8BitPerChannel(uint8_t* image, const uint8_
}
}

ocean_assert(pixels != 0);
ocean_assert(pixelBoundingBox.isValid());

if (pixels == 0)
{
return false;
}

uint8_t averageColors[tChannels];

for (unsigned int n = 0u; n < tChannels; ++n)
Expand All @@ -145,8 +153,6 @@ bool FrameFilterBlur::blurMaskRegions8BitPerChannel(uint8_t* image, const uint8_
}
}

pixels = 0u;

for (unsigned int y = pixelBoundingBox.top(); y < pixelBoundingBox.bottomEnd(); ++y)
{
const uint32_t* const rowSepartion = separation.constrow<uint32_t>(y);
Expand All @@ -160,8 +166,6 @@ bool FrameFilterBlur::blurMaskRegions8BitPerChannel(uint8_t* image, const uint8_
{
rowImage[x * tChannels + n] = averageColors[n];
}

++pixels;
}
}
}
Expand All @@ -176,6 +180,8 @@ bool FrameFilterBlur::blurMaskRegions8BitPerChannel(uint8_t* image, const uint8_

ocean_assert(maskBlocks.size() == pixelBoundingBoxes.size());

CV::PixelPositions borderPixels;

for (size_t n = 0; n < maskBlocks.size(); ++n)
{
const CV::PixelBoundingBox& pixelBoundingBox = pixelBoundingBoxes[n];
Expand All @@ -193,8 +199,6 @@ bool FrameFilterBlur::blurMaskRegions8BitPerChannel(uint8_t* image, const uint8_

Frame blendMask = imageMask.subFrame(extendedBoundingBox.left(), extendedBoundingBox.top(), extendedBoundingBox.width(), extendedBoundingBox.height(), Frame::CM_COPY_REMOVE_PADDING_LAYOUT);

CV::PixelPositions borderPixels;

for (unsigned int iteration = 1u; iteration < blurBorder; ++iteration)
{
borderPixels.clear();
Expand Down

0 comments on commit cbbcf39

Please sign in to comment.