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

Fully integrate tracking, rewrite UI integration #87

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tfaehse
Copy link
Owner

@tfaehse tfaehse commented Feb 5, 2024

- blurrer is independent from UI, CLI via generic progress handler
- execution in three stages: detection, tracking, blurring
- choose mps backend automatically on supported hardware (ARM macOS machines)
- add norfair box tracker
- perform tracking forwards and backwards in time

    - blurrer is independent from UI, CLI via generic progress handler
    - execution in three stages: detection, tracking, blurring
    - choose mps backend automatically on supported hardware (ARM macOS machines)
    - add norfair box tracker
    - perform tracking forwards and backwards in time
@thkukuk
Copy link

thkukuk commented Feb 6, 2024

With the rename of the options, the Dockerfile needs to be adjusted, too.

@thkukuk
Copy link

thkukuk commented Feb 6, 2024

I did build a container with this PR and got the following error (options were -w 1080p_medium_v8 -t 0.1 -q 5.5 -b 29)

Detecting plates and faces...: 100%|████████████▉| 9065/9067 [6:04:47<00:04,  2.41s/frames]
Running forward tracking...: 100%|████████████████| 9064/9064 [00:13<00:00, 673.96frames/s]
Running backward tracking...: 100%|███████████████| 9063/9063 [00:13<00:00, 654.61frames/s]
Writing blurred video...:  10%|█▊                 | 868/9067 [17:02<1:58:42,  1.15frames/s]concurrent.futures.process._RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 205, in _process_chunk
    return [fn(*args) for args in chunk]
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 205, in <listcomp>
    return [fn(*args) for args in chunk]
  File "/app/src/blurrer.py", line 296, in blur_helper
    return apply_blur(frame, index, detections_dict, parameters)
  File "/app/src/blurrer.py", line 343, in apply_blur
    cv2.ellipse(blur_area, center, axes, 0, 0, 360, color=mask_color, thickness=-1)
cv2.error: OpenCV(4.9.0) /io/opencv/modules/imgproc/src/drawing.cpp:1953: error: (-215:Assertion failed) axes.width >= 0 && axes.height >= 0 && thickness <= MAX_THICKNESS && 0 <= shift && shift <= XY_SHIFT in function 'ellipse'

"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/app/cli.py", line 271, in <module>
    cli.start_blurring()
  File "/app/cli.py", line 58, in start_blurring
    self.start_blurring_file()
  File "/app/cli.py", line 69, in start_blurring_file
    blurrer.execute_pipeline()
  File "/app/src/blurrer.py", line 144, in execute_pipeline
    self.write_video(tracking_results)
  File "/app/src/blurrer.py", line 36, in decorator
    return fn(self, *args, **kwargs)
  File "/app/src/blurrer.py", line 220, in write_video
    for frame_blurred in blur_executor.map(blur_helper, args):
  File "/usr/lib/python3.10/concurrent/futures/process.py", line 575, in _chain_from_iterable_of_lists
    for element in iterable:
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 621, in result_iterator
    yield _result_or_cancel(fs.pop())
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 319, in _result_or_cancel
    return fut.result(timeout)
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 458, in result
    return self.__get_result()
  File "/usr/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
    raise self._exception
cv2.error: OpenCV(4.9.0) /io/opencv/modules/imgproc/src/drawing.cpp:1953: error: (-215:Assertion failed) axes.width >= 0 && axes.height >= 0 && thickness <= MAX_THICKNESS && 0 <= shift && shift <= XY_SHIFT in function 'ellipse'

Writing blurred video...:  10%|█▊                 | 868/9067 [17:12<2:42:32,  1.19s/frames]

- use numpy for clipping
- ensure correct min/max definition of bounding box points
@tfaehse
Copy link
Owner Author

tfaehse commented Feb 6, 2024

Thank you for the feedback.
I could reproduce the issue, failed tracks could possibly result in negative axes for the ellipse. The new commit should fix this.

@thkukuk
Copy link

thkukuk commented Feb 7, 2024

I tested the new commit with two videos, no crash, seems to work fine, but there is a bug: the plates and faces of the last four pictures are never blurred.

@tfaehse tfaehse marked this pull request as draft February 11, 2024 10:25
@tfaehse
Copy link
Owner Author

tfaehse commented Feb 11, 2024

Thank you for the feedback!
There are a few more bugs to be fixed, and I'm experimenting with a few more improvements (like using botsort integrated with the detector, and running some simple filtering of tracked obstacles that aren't actively detected anymore), so I've converted this to a draft again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants