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

TimeUnit conversion helpers #221

Closed
keighrim opened this issue Jun 19, 2023 · 0 comments · Fixed by #233
Closed

TimeUnit conversion helpers #221

keighrim opened this issue Jun 19, 2023 · 0 comments · Fixed by #233
Labels
✨N New feature or request

Comments

@keighrim
Copy link
Member

New Feature Summary

As a subtask to #206 , Id like to see addition of time unit conversion code in this package. A few things to consider implementation-wise;

  • currently we use three units; frame, milliseconds, and seconds.
  • there could be some alternative spellings of the units in use (some examples;
    • frames: frame
    • seconds: second, sec, s
    • milliseconds: millisecond, msec, ms
  • for conversion from/to frames, code needs to know fps of the video, and there could be two possible sources of the information under the current specification
    • in the Annotation annotation this should be obtainable via something like this
    ann_v = mmif.get_views_for_document('vd1')
    ann_ann = ann_v.get_annotation(AnnotationTypes.Annotation)
    fps = ann_ann.properties['framerate']
    # again, there may be alternative keys ('frame-rate', 'frames-per-second', 'fps', ...)
    • from the video directly
    vd = mmif.get_document_by_id('vd1')
    vobj = cv2.VideoCapture(vd.location_path)
    fps = vobj.get(cv2.CAP_PROP_FPS)
    • note that the second method requires some video processing software under the hood (opencv, ffmpeg, etc), but I don't like to ship mmif-python package with a full opencv dependency. Hence we might need to consider implementing this part as a plugin package.

Related

#206 and remotely related to clamsproject/app-east-textdetection#1

Alternatives

We could just leave this implementation to app developers. Some existing code that does time unit conversion

  1. as output unit

https://github.com/clamsproject/app-east-textdetection/blob/e7f2549fc875fd5c1762a3046de68ea67a82140d/app.py#L71-L81

  1. as input unit

https://github.com/clamsproject/app-parseq/blob/7f4476775f708f8ee23aaad2dc3210d327b0f8c9/app.py#L27-L38

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨N New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant