microsoft / opencv

Open Source Computer Vision Library
opencv.org
Apache License 2.0
144 stars 92 forks source link

Optimization on Windows Phone (e.g. Lumia 920) #1

Closed izaxon closed 9 years ago

izaxon commented 10 years ago

We develop an SDK for road sign recognition on Windows Phone. It is a port from iOS and Android. Performance on e.g. a Lumia 920 is not so good at the moment. Will there be optimization efforts of OpenCV for Windows Phone planned that will improve performance? Also, what can we do/investigate to improve our classifier on Windows Phone at the moment?

stammen commented 10 years ago

Wow! Sounds like a very cool app. What kind of performance differences are you seeing in release builds when compared to iOS or Android?

Currently the Windows Phone 8.0 (WP8) does not support any GPU acceleration of the OpenCV functions as it is missing OpenCL or CUDA support. You might be able to improve performance by putting your OpenCV recognition code on a separate thread.

izaxon commented 10 years ago

We get 5-6 fps on the Lumia 920. On Android (Nexus 5) and the iPhone 5S we get about 5-6 times the fps. We will test on a Lumia 1520 the coming week. It has a comparable CPU as the Nexus 5.

Do you know about planned Intel TBB for Windows Phone 8. TBB is used internally by OpenCV. And what about GPU acceleration support. Is that planned?

stammen commented 10 years ago

It appears that TBB is currently available for WinRT but not WP8. There is no available method for GPU acceleration for WP8.

UzEE commented 10 years ago

@izaxon Did you see any improvements with the 1520?

I'm also porting an OpenCV based app on Lumia 920 (http://groopic.com) and the performance on the device is leagues behind iOS and Android.

The same algorithms on iOS and Android work near realtime, while those operations take about 6-7 seconds on the Lumia 920.

izaxon commented 10 years ago

Yes, we got about twice the frame rate (fps) on the Lumia 1520.

UzEE commented 10 years ago

@stammen The WP8 version also doesn't support PPL and Concurrency internally, meaning that most CV operations are running single threaded and not utilizing all available CPU cores (at least according to some tests I've ran).

I've noticed that you specifically disabled HAVE_CONCURRENCY if HAVE_WINRT is defined.

I don't have much experience with C++/CX (C++ in general) but certain parallel algorithms like parallel_for and parallel_for_each work on Windows Phone, from what I've tested at least.

Have you gotten around to tweaking the code to support concurrency and parallel constructs for WinRT and WP8?

It should help boost overall performance.

izaxon commented 10 years ago

Hi, we didn't tweak OpenCV but used create_task (from PPL) to parallelize our road sign recognizer. Here is a code excerpt from our Direct3DInterop::ProcessFrame():

// Process right and left detection areas at the same time... auto taskRight = create_task([&]() { cascadeAllRight.detectMultiScale(_right, ...); }); { cascadeAllLeft.detectMultiScale(_left, ...); } taskRight.wait();

A3RITHwork commented 9 years ago

Hi izaxon, i'm a student and currently develloping an aplication similar to yours. Using openCV i need to recognize simple forms on cards. We will use a Windows Phone 8.1. I've built opencv i can include it in my projects, but i can't access to the highgui functions like 'imread'. In the openCV solution there is no highgui project, so there is no highgui.lib created. In many of the exemples i learn from there is a highgui.lib used, so i'm a bit confused...

stammen commented 9 years ago

We have not yet implemented the highgui libs for winrt/wp8. We plan to do so in the coming months.

stammen commented 9 years ago

@A3RITHwork please open a new issue so we can track it. Thanks.

A3RITHwork commented 9 years ago

Sorry, thank you for the quick reply.

mkostin commented 9 years ago

@izaxon, @UzEE, concurrecy support has been contributed to the main OpenCV repository. Take a look at referenced performance tests reports. Closing this ticked, feel free to reopen it if necessary.