shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.4k stars 1.15k forks source link

Performance of 64 bit 2.4.9 #54

Closed TerryEss closed 7 years ago

TerryEss commented 10 years ago

I have been using OpenCVSharp for a number of years. For a number of reasons I have continued to use version 2.3 even thought it is 32 bit and I work with 64 bit machines now days. I decided to try the latest, 64 bit 2.4.9 , using NuGet to load the package. Things worked well until I ran the results. In my application I am using both video and depth from a Kinect. The video data is processed with a "blue filter" and then passed on to OpenCvSharpBlob in order to find a "target". The 2.3 version had 24% better performance then the 2.4.9 version. In both cases I am using the OpenCv dll's provided with the OpenCvSharp package and the computer used was the same 64 bit Windows 7 machine. Any idea why the performance is so poor? Is there anything I can do to improved the performance? The application directs an autonomous robot and the performance hit makes the new version unusable.

shimat commented 10 years ago

This is the first I have heard about it. How about "32-bit" 2.4.9 performance on your environment?

TerryEss commented 10 years ago

I am in the middle of a significant rebuild, software and electronics, so I will not be able to answer your question until next week. At that point I will try to have a more complete characterization of the performance difference between versions and platforms.

TerryEss commented 10 years ago

I have had a chance to do a more detailed look at the 32 vs 64 bit performance issue. My tests determined the average elapsed processing time per frame to handle what is in my case the heaviest calculation load. Bottom line, the 32 bit versions using OpenCVSharp 2.3 or 2.4.9 are pretty much the same. The 64 bit version using OpenCVSharp 2.4.9 is significantly slower. The majority of the slow down is in the non-OpenCV code but some is in the OpenCV code. The impact varies with he PC. I used two different machines, a Windows 7 i5 based desktop and a Windows 8.1 i3 based laptop. The general results were the same but the magnitude of the difference was much larger on the laptop.

Background on the robot that I am building can be found at http://www.silver-bullet-technology.com/george.htm, The processing iis the worst case load the robot experiences. In this case the robot is moving towards a blue "target" which indicates "home". Do do this I need to determine the relative angle and distance to the target. The Kinect event handler gets a video and depth frame from the Kinect every 33.3 msec (30 fps). The video data goes through a blue filter and then blob processing to find the target. The relative angle is determined by the number of pixels off-center the centroid of the blob is. Determining the distance to the blob requires that the depth frame be mapped to the video frame and then the centroid location be found in the map.

I can send you a zip file with all the test results, source code for the class with the frame processing etc.