-
-
Notifications
You must be signed in to change notification settings - Fork 827
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
Keyframe Selection: Rework and add new selection methods #1343
Conversation
52da6df
to
e9567f9
Compare
e9567f9
to
2098f0a
Compare
Would be great to be able to export in other formats (jpg, png, etc.) |
There seem to be a problem when writing the selected frames: images are brighter than they should be (maybe a gamma is applied ?) |
It would be also nice to add a |
2098f0a
to
52d0f50
Compare
Added! Currently supported formats are exr, jpg and png.
There was indeed an issue with the colorspace for input videos, it is now fixed! |
All done! |
An option that could be interesting for users would be to automatically rename the exported frames with their frame number within the output sequence. Example:
I don't know if it makes sense to add that feature here or if we should juste let users take care of the renaming with some other software, but in my case I know I would definitely use it 😅 |
6fcb181
to
021d9ab
Compare
This was very easy to add and not costly at all, so I added an option to do what you described ( |
Might be a good idea to add some info logs (using |
a8c54b4
to
1b433ca
Compare
I have promoted some "DEBUG"-level logs to "INFO" for the smart selection, so we now have some info about the progress of the score computation with the default verbose setting. |
1b433ca
to
36cfdf6
Compare
Keyframes may be written as JPG, PNG or EXR files. If the EXR format is selected, the storage data type can be specified as well.
…scores The rescaled frames used to compute the sharpness and motion scores used to be the same, with a single parameter to specify the rescale value. As we may want to use different rescale values depending on whether we are computing the sharpness or the motion score (or no rescale for one but a rescale for the other), the existing "rescaledWidth" parameter is split into two new parameters, "rescaledWidthSharpness" and "rescaledWidthFlow".
919c408
to
16ddd12
Compare
By default, the selected keyframes are written with their index within the input sequence / video as their name. If frames at index 15, 294 and 825 are selected as keyframes, they will be written as 00015.exr, 00294.exr and 00825.exr. This commit adds an option that allows to name them as consecutive frames instead. Frames at index 15, 294 and 825 are now written as 00000.exr, 00001.exr and 00002.exr if the option is enabled.
If a frame is missing in a video sequence, instead of throwing an exception straight away, try reading the next frame. If the next frame is valid, then push dummy scores for the missing frame, and keep processing the input video. Otherwise, do throw the exception and stop the process. The dummy scores will be ignored in the final keyframe selection (explicitly in the case of the motion accumulation computation, implicitly when applying the weights during the sharpness selection).
"getSupportedExtensions" used to get the content of OIIO's "extension_list" and parse it. OIIO now provides a utility function that does the parsing of "extension_list" and returns it into a map. Using it directly simplifies the function's body. The documentation is also updated with more details.
…format "isSupported()" relies exclusively on the content of OpenImageIO's "extension_list", which contains all the formats supported as inputs, including video formats, with no distinction. A function "isVideoExtension" is added to determine whether the input extension is part of the OIIO-supported movie formats. The list of supported formats is hard-coded based on OIIO's documentation.
For ImageFeed: use image::isSupported and image::isVideoExtension to check that the input is supported by OpenImageIO but is not a video. For VideoFeed: add a VideoFeed::isSupported method to ensure that we do not try to open unsupported videos with OpenCV. The list of supported video formats is provided by OpenImageIO, which is based on ffmpeg like OpenCV. Both ImageFeed and VideoFeed have their own implementation of isSupported to ensure they can check whether they support a given input on their own.
Propagate the pixel aspect ratio for EXR and PNG outputs. For JPG outputs, writing the pixel aspect ratio in that way leads to errors, as any aspect ratio > 1 is written as < 1.
JPG images are always supposed to be in sRGB. When this information is available, it is better to include it in the "fromColorSpace" when writing the output to ensure the colorspace is appropriate.
Add a "skipSharpnessComputation" debug option that allows to compute the scores with performing the sharpness score computations. All frames will be assigned a fixed sharpness score of 1.0. If the smart selection is applied with this option enabled, the selected frames will be those located in the center of each subset (determined with the motion scores) as the weights will be applied on constant scores. This option is useful to determine the impact of the sharpness score computation on the global processing time.
16ddd12
to
4f1f4db
Compare
Description
This PR is a replacement for #1213 and aims at completely reworking the Keyframe Selection utility.
It removes the existing selection methods and replaces them with two selection methods:
This was already possible with the existing Keyframe Selection utility, but has been simplified to be more user-friendly.
The goal is to select a frame that is as sharp as possible with significant motion compared to the previously selected frame: consecutive frames should not be selected as keyframes if they do not contain enough motion, even if they are both very sharp. The level of motion that is deemed significant can be adjusted with parameters, as well as the minimum and maximum number of expected keyframes.
Additionally, debug options have been added:
The name of output frames can also be chosen between two options:
Videos, sequences of images and camera rigs are supported as inputs.
The corresponding Meshroom pull request can be found here: alicevision/Meshroom#1880
Features list
Implementation remarks
N.B: The most obvious performance improvement that could be done would concern the sliding window: it currently slides pixel by pixel across all the image, which is very time-consuming but doesn't necessarily bring in more information than if it was sliding faster.
and its position in the subsequence (frames located at the middle have an advantage over frames located on the subsequence's borders). The goal is to select frames that show a significant difference in their motion, are not too close to each other in time, and are as sharp as possible.
Known limitations