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

Fix opencv crash #495

Merged
merged 11 commits into from
Sep 26, 2021
Merged

Fix opencv crash #495

merged 11 commits into from
Sep 26, 2021

Conversation

ckuethe
Copy link
Collaborator

@ckuethe ckuethe commented Sep 21, 2021

This depends on the previous PR to add getopt. Now that I have getopt, it's easy to add extra flags to do useful things, like filtering improperly sized images to avoid opencv assertion failures.

@EricClaeys
Copy link
Collaborator

For the --fontcolor in keogram.cpp, would it be possible to allow both "#00ff00" format and "000 255 000" format (enclosed in quotes)? A lot of non-experienced users (and some experienced ones) find hex notation more difficult than a regular number. For example, what's half of "ff", versus half of 255?
One way to implement would be if there's a space in the string, it's the second format, otherwise the first.

@ckuethe
Copy link
Collaborator Author

ckuethe commented Sep 22, 2021

I though about that but decided against it in the interests of simplicity of parsing. There are lots of html color calculators online.

@EricClaeys
Copy link
Collaborator

@ckuethe I don't think making things easier for a programmer but harder for a user is the way to go.
By requiring the "000 255 000" be in quotes, the fontcolor will be treated as one argument and can be parsed like it's done in capture.cpp: sscanf(argv[++i], "%d %d %d", &fontcolor[0], &fontcolor[1], &fontcolor[2]);
The keogram.cpp code could either check for a space, or try the sscanf() and if it doesn't return 3, use the #ffffff method.

@ckuethe
Copy link
Collaborator Author

ckuethe commented Sep 24, 2021

Rebased.

@ckuethe
Copy link
Collaborator Author

ckuethe commented Sep 24, 2021

Also mitigates #492

ckuethe and others added 11 commits September 26, 2021 11:56
Add a new size flag, eg. `-s 1280x960` to ignore images not matching the
specified size. Not sure where the improperly sized images are coming from
(maybe truncated writes to disk?) but this allows me to just reject them
and keep OpenCV from exploding.
What is it with my system, finding all of these broken images?!

Anyway, somehow I've got a few monochrome images scattered through
my directory of RGB, which of course makes OpenCV get its knickers
in a knot. To mitigate this, I take the first image of appropriate
dimension, and use its channel count as authoritative. Any images
not matching that will be converted.
getopt(3) returns int not char, and document the size filter
allow font color to be specified in opencv order as a string of 3 ints
representing blue, green and red channels, eg. "255 128 64" as well as
in the usual rgb hex format, eg. "c0ffee" or "#3333cc".

and add a "-p"/"--parse-filename" flag to derive the image time from the
filename rather than its time on disk (which may not be preserved across
copies. Fixes #503
@ckuethe
Copy link
Collaborator Author

ckuethe commented Sep 26, 2021

Just to clarify what's going in here, I found a few edge cases when reprocessing old images.

  • number of channels unexpected (eg. trying to work with both color and monochrome images). fixed by changing colormap of offending image on the fly.
  • image size varying (somehow I got unexpected sizes of images). fixed by adding skipping images with unexpected size
  • keograms would be missing time markers (timestamps not read from disk correctly). fixed by adding a flag to extract timing information from the filename)

Copy link
Collaborator

@linuxkidd linuxkidd left a comment

Choose a reason for hiding this comment

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

Code looks sound!

@linuxkidd linuxkidd merged commit 7411cf6 into AllskyTeam:master Sep 26, 2021
@ckuethe ckuethe deleted the fix_opencv_crash branch September 27, 2021 04:03
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.

None yet

3 participants