alemart / speedy-vision

GPU-accelerated Computer Vision for JavaScript.
Apache License 2.0
175 stars 28 forks source link

FAST detector is slow to get results #16

Closed fzy139 closed 3 years ago

fzy139 commented 3 years ago

Hi, I'm using speedy's FAST feature detector to accelerate the opencv FAST. In my case there requires around 300 feature pts each frame. After profiling, the detector itself costs about 8 ms, but the time to get the result is more than 30ms. Is that normal? Any ways to speed up except reducing the feature pts?

Codes are like that: detector.detect(media).then(result=>{ // do some work with the feature points );

device info: Chrome 90 on pixel 2. Update: image There are lots of tasks checking status... I think that's why so slow to get the res.

Any way, thanks for your wonderful works ~

alemart commented 3 years ago

Hi,

Performance depends, among other things, on the size of the media and on the number of keypoints.

the detector seems costs more than 30ms

The detector is usually a lot cheaper than that. Since your picture shows 8.35 ms for detect, this profile seems unusual.

I don't know your use case, so please try profiling FAST on this demo.

fzy139 commented 3 years ago

Thanks for your fast reply, @alemart. The input is a canvas of size 180 * 320. I also profile the demo in your repo with my data. The situation is similar with above. image I add a timer to show the actual time it costs to return the results.

// find features
console.time('detect')
const features = await featureDetector.detect(media);
console.timeEnd('detect')

By the way, in my case the detect function itself indeed costs 8 ms, but returning the results costs more than 30ms. Sorry about that if I'm not clear.

alemart commented 3 years ago

Hi fzy139,

I am not sure what you are measuring. In your history of posts, there is a picture showing a 0.54ms time for detect in my demo, is that correct? That seems compatible to what I get.

The thin columns represent the CPU waiting for the GPU to deliver the results. It takes about 9-10ms in this picture, which is okay.

You may find it useful to start with one of my demos, which have higher performance, and then gradually add new content to it. You'll likely find some clues by trial and error. Maybe the GPU is busy doing something else.

fzy139 commented 3 years ago

Hi @alemart I'm measuring the time between the detect function is invoked and its results is returned, as the orange column tagged 'detect' in my last post.

console.time('detect')
const features = await featureDetector.detect(media);
console.timeEnd('detect')

Yes the profiling your mentioned is the original demo, but when I replace the media with my own data (without other codes). Same device and profile again, the time increases twice. And the image I use is smaller than the video in your demo. Strange, right? If the transmission between CPU and GPU takes lots of time, why the two results differ so much? Any ways to reduce it?

I can send you some of my data and you could test them on your device. Thanks! :)

alemart commented 3 years ago

I can send you some of my data and you could test them on your device. Thanks! :)

If you need specialized help for your use case, contact me on Otechie. I can take a deeper look into your data.