Skip to content

Conversation

wbruna
Copy link
Contributor

@wbruna wbruna commented Sep 27, 2025

No description provided.

The sd_image_t struct is passed by value, so the data pointer
can't be changed. Instead, just overwrite the image data area.
@wbruna wbruna force-pushed the fix_canny_preprocessing branch from 7b8adc1 to 0986a21 Compare October 12, 2025 21:25
@leejet
Copy link
Owner

leejet commented Oct 13, 2025

It looks like this just increases the size of mem_size?

@wbruna
Copy link
Contributor Author

wbruna commented Oct 13, 2025

The struct is also received by value, so freeing the data buffer leaves behind an invalid pointer; so I'm reusing the existing buffer instead..

@leejet
Copy link
Owner

leejet commented Oct 13, 2025

So it’s just to avoid reallocating memory, and it won’t affect the result?

@wbruna
Copy link
Contributor Author

wbruna commented Oct 13, 2025

So it’s just to avoid reallocating memory, and it won’t affect the result?

It's more like 'avoid changing the data pointer', since we can't alter its value for the code layers above (it's a C interface). It shouldn't affect the canny processing result in any way: the input image is only used to initialize the tensors, so it's safe to overwrite it at that later point.

(of course, on current master, the data pointer ends up pointing to a freed buffer, so the image data could have been changed (corrupted) by the program elsewhere. In that sense, image results could be different.)

@leejet
Copy link
Owner

leejet commented Oct 13, 2025

I forgot that the parameter is passed by value, so it makes sense.

@leejet
Copy link
Owner

leejet commented Oct 13, 2025

Thank you for your contribution.

@leejet leejet merged commit 5436f6b into leejet:master Oct 13, 2025
8 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.

2 participants