frigate: [Bug/Degradation]: High CPU Usage With Motion Detection

Describe the problem you are having

after some latest commits, related to motion detection, it’s works worse then before

Version

dev-7c1568f

Frigate config file

same as in #6802

Relevant log output

irrelevant, no errors/warnings etc

FFprobe output from your camera

irrelevant

Frigate stats

No response

Operating system

UNRAID

Install method

Docker CLI

Coral version

USB

Network connection

Wired

Camera make and model

netatmo welcome

Any other information that may be helpful

frigate-stationary-degradation

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 51 (26 by maintainers)

Most upvoted comments

I spent some time trying to back out specific parts of the new motion detector to see what was driving the change in CPU usage.

I found that if I removed both the gaussian blur and contrast improvement calls, the CPU usage dropped back to very low levels.

What is interesting is that adding either of them increases CPU usage to the elevated levels. Adding a second one doesn’t seem to increase levels further. It doesn’t matter which one is enabled, just that at least one is.

I’m wondering if there is some underlying overhead associated with the opencv interface to python that initializes once for a given scope. I did try updating to the latest opencv and it reduced the CPU usage by half, but it’s still elevated with either of those function calls enabled.

Just some weird python shit. One day I want to port this part of the code base to rust or something.

Another idea would be to look at doing the same operations in numpy and optimizing with numba, but there is a bunch of other opencv stuff in there.