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 brightness computation for all bayer image types #217

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum PixelFormat {
};
std::string to_string(PixelFormat f);
PixelFormat from_nodemap_string(const std::string pixFmt);
bool is_bayer(PixelFormat f);
} // namespace pixel_format
} // namespace spinnaker_camera_driver
#endif // SPINNAKER_CAMERA_DRIVER__PIXEL_FORMAT_HPP_
7 changes: 7 additions & 0 deletions spinnaker_camera_driver/src/pixel_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <spinnaker_camera_driver/pixel_format.hpp>
#include <string>
#include <unordered_map>
#include <unordered_set>

namespace spinnaker_camera_driver
{
Expand Down Expand Up @@ -81,12 +82,18 @@ static const std::unordered_map<std::string, PixelFormat> string_2_fmt{
{"BGR8", BGR8},
{"BGRa8", BGRa8}}};

static const std::unordered_set<PixelFormat> bayer_formats{
BayerRG8, BayerRG10p, BayerRG10Packed, BayerRG12p, BayerRG12Packed, BayerRG16,
BayerGR8, BayerGR16, BayerGB8, BayerGB16, BayerBG8, BayerBG16};

PixelFormat from_nodemap_string(const std::string pixFmt)
{
auto it = string_2_fmt.find(pixFmt);
return (it == string_2_fmt.end() ? INVALID : it->second);
}

bool is_bayer(const PixelFormat f) { return (bayer_formats.find(f) != bayer_formats.end()); }

std::string to_string(PixelFormat f)
{
auto it = fmt_2_string.find(f);
Expand Down
2 changes: 1 addition & 1 deletion spinnaker_camera_driver/src/spinnaker_wrapper_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static int int_ceil(size_t x, int y)
static int16_t compute_brightness(
pixel_format::PixelFormat pf, const uint8_t * data, size_t w, size_t h, size_t stride, int skip)
{
if (pf != pixel_format::BayerRG8) {
if (!pixel_format::is_bayer(pf)) {
return (0);
}
const uint64_t cnt = int_ceil(w, skip) * int_ceil(h, skip);
Expand Down
Loading