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

Add layouts #1

Merged
merged 1 commit into from
Sep 8, 2024
Merged

Add layouts #1

merged 1 commit into from
Sep 8, 2024

Conversation

griswaldbrooks
Copy link
Owner

No description provided.

Copy link

@briancairl briancairl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some quick stuff.

Is there anything in particular you want feedback-wise?

src/map.cpp Outdated Show resolved Hide resolved
src/map.cpp Outdated Show resolved Hide resolved
src/map.cpp Outdated Show resolved Hide resolved
src/map.cpp Outdated Show resolved Hide resolved
src/map.cpp Show resolved Hide resolved
Copy link
Collaborator

@bgill92 bgill92 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass

src/map.cpp Outdated Show resolved Hide resolved
src/main.cpp Show resolved Hide resolved
src/map.cpp Outdated Show resolved Hide resolved
src/map.cpp Outdated Show resolved Hide resolved
src/map.cpp Outdated Show resolved Hide resolved
// We know ptr will be valid asynchronously because we construct it on the
// stack of main. In real code we might want to use a shared_ptr or
// something
return std::async([=] {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bold and daring of you

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why so?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its implementation-defined, but I think std::async usually launches a new thread, so its sort of doodoo. But there's no read/write sync on the data pointed to by ptr. I would guess your serial::Serial interfaces do some of their own protection, calling into the same offset could be weird?

src/map.cpp Outdated

// Populate the Mat with the data from the array (scale from int to 8-bit
// range)
for (auto i = 0u; i < Width * Height; ++i) {
Copy link

@briancairl briancairl Sep 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::transform(
  std::begin(grid),
  std::end(grid),
  img.begin<uchar>(),
  [](auto grid_value) -> uchar
  {
    return static_cast<uchar>(std::clamp(16 * grid_value, 0, 255));
  } 
);

less loopy index-y, but you probably need grid.begin() and grid.end()

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or i could do neither of those things

@griswaldbrooks griswaldbrooks merged commit f94f3ce into main Sep 8, 2024
3 of 19 checks passed
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.

3 participants