0

I want to have multiple camera that processing by unique filter and all camera filter have to access to unique Array in memory(should not passing copy of Array to each filter).

Do you have any idea? my solution is to send the Array by parameter to QAbstractVideoFilter, but dont know how to do that and how it possible ?

Rashed DIP
  • 57
  • 8

1 Answers1

1

You will need to reimplement QAbstractVideoFilter::createFilterRunnable, which will return your custom filter class inherited from QVideoFilterRunnable. This allows you to declare and implement any interface, parameters and communication in your class, which will affect video filtering/processing.

So, you'll have two own classes:

  1. Inherited from QAbstractVideoFilter
  2. Inherited from QVideoFilterRunnable

You can make changes in each one, but I recommend you to make your interface in QAbstractVideoFilter and then forward to spawned QVideoFilterRunnable.

To make your interface work in QML, you should:

  • Register your class with qmlRegisterType
  • Use QML-compatible types (or/and register these types for QML)
  • Use Q_PROPERTY and Q_INVOKABLE where it's needed
Ihor Drachuk
  • 1,265
  • 7
  • 17
  • Thanks for your complete answer, but i know that in real, my main problem is how to send an Array to many instance of filters for each camera, but all filters should access to unique location of memory(the array), not copy – Rashed DIP Jul 28 '20 at 17:41
  • Pass `std::shared_ptr` to filters. Or `shared_ptr` with some information+Array. So, Array could be accessed from filters and from other owners of it's copy, but Array will be single in memory. Mentioned `Struct` could contain `mutex` if needed. 2nd copy of these shared_ptrs could be controlled by some another class with QML-compatible interface – Ihor Drachuk Jul 28 '20 at 19:28
  • Is it your mean to define a public class including a shared-pointer and passing instance of it to all filters class? – Rashed DIP Jul 28 '20 at 19:29
  • Mostly yes, or something like that. See example here: https://pastebin.com/zgULa18h And after doing like that, register `FiltersController` in QML. And therefore you can control Filters via FiltersController from QML – Ihor Drachuk Jul 28 '20 at 19:34
  • Do you think if i create two instance of MyFilter for two camera(two VideoOutput), both access to the same ArrayData in FiltersController or two instance of FiltersController ? – Rashed DIP Jul 28 '20 at 19:56
  • I assume it could be done as you need. Both Filters can share same ArrayData or can use each it's own copy of ArrayData but shared only with Controller. So, Controller can contain one ArrayData or several for each Filter. – Ihor Drachuk Jul 28 '20 at 22:32
  • I don't recommend to use two instances of FiltersController, but you can go this way and it will work as well – Ihor Drachuk Jul 28 '20 at 22:40
  • have you any suggestion for my program? i have many camera and very big array, i should processing each frame and compare it with my big array. – Rashed DIP Jul 29 '20 at 04:30
  • 1
    You have some kind of video processing, so I recommend solutions from this category: parallel computing (use all CPU cores or video card), OpenCL, CUDA, SIMD. Make sure you efficiently use system resources – Ihor Drachuk Jul 29 '20 at 09:41