GithubHelp home page GithubHelp logo

Copy implementation about js-objectdetect HOT 10 CLOSED

mtschirs avatar mtschirs commented on June 17, 2024
Copy implementation

from js-objectdetect.

Comments (10)

mtschirs avatar mtschirs commented on June 17, 2024

Hi inspirit,

I do not mind anybody using code of js-objectdetect, however there might be a licensing issue as js-objectdetect is currently released under GPLv3 (I could perhaps switch to MIT).

However, you should perhaps know that the code used in this library was initially created to serve as a "quick" reference implementation for a GPU based face detector (using WebGL). The code is only compatible to stump based HAAR cascades (https://github.com/foo123/HAAR.js supports all cascades) and has not been tested as thoroughly as it perhaps should have been.

Since canny pruning does not really seem to be effective / increase performance at all, I did not really care that much about further optimizing it. Perhaps your gaussian / canny methods might change that.

Concerning the grayscale conversion, I did some jsperf-tests (http://jsperf.com/convert-rgba-to-grayscale). Performing integer operations instead of floating point operations on the image-data seems to increase performance in all browsers except for IE. Adding more code to the body of the loop however does not change that much. Interestingly, the 8-bit shift integer-version decreased detection performance on the test images (http://mtschirs.github.com/js-objectdetect/examples/example_image.htm). This is because OpenCV (HAAR classifier training) uses 0.299_R + 0.587_G + 0.114_B for RGB to grayscale conversion while your 8-bit shift integer code uses approx. 0.301_R + 0.590_G + 0.109_B. Therefore I now use a 10 bit shift which more closely resembles the OpenCV conversion.

Best regards,
Martin

from js-objectdetect.

inspirit avatar inspirit commented on June 17, 2024

hey, thanx for the info. according to license, yes i use MIT for my code. how ever i put all the info about original author :) anyway i will look at another implementation u mentioned to get best of both worlds. personally i dont think that grayscale conversion coeefs will have any significant impact. i also tested different ways to convert to grayscale:
http://jsperf.com/math-vs-lut-grayscale

from js-objectdetect.

inspirit avatar inspirit commented on June 17, 2024

to replicate the same grayscale as presented in OpenCV:

var coeff_r = 4899, coeff_g = 9617, coeff_b = 1868;
var pix_gray = ((coeff_r*pix_r + coeff_g*pix_g + coeff_b*pix_b) + 8192) >> 14;

this is using fixed point math to convert float coeffs to integers and then scale back. the same OpenCV used in thei ColorConvert method

from js-objectdetect.

mtschirs avatar mtschirs commented on June 17, 2024

"personally i dont think that grayscale conversion coeefs will have any significant impact" - Well, they have. Using your 8-bit shift coefficients, performance is reduced by 33% in http://mtschirs.github.com/js-objectdetect/examples/example_image.htm. A 10 bit shift seems to have much lesser impact on detection performance there. The 14 bit shift you presented is of course even better, however large shift values also seem to reduce run time performance.

Thank you for all the interesting input though, a closer look at your code reveals some interesting js performance tricks.

from js-objectdetect.

inspirit avatar inspirit commented on June 17, 2024

well taking into account 160x120 image conversion time only about 1-3ms i think we should go 14 bit version to get best detection result. i've updated my grayscale method to this latest coeffs.
and if user wants to run detection on large/original image it wont be realtime in any case and grayscale time doesnt really matter.

from js-objectdetect.

mtschirs avatar mtschirs commented on June 17, 2024

yes, you are probably right. It also seems that a bigger shift value only slighly impacts performance on FF while there seems to be no difference for the other browsers.

from js-objectdetect.

inspirit avatar inspirit commented on June 17, 2024

btw i did first merge of your implementation:
http://inspirit.ru/jsfeat/haar/

seems to work quite nice.

i also implemented different detection algo (BBF) u can take a look here:
http://inspirit.ru/jsfeat/bbf/

from js-objectdetect.

mtschirs avatar mtschirs commented on June 17, 2024

Looks good!

from js-objectdetect.

adamjbradley avatar adamjbradley commented on June 17, 2024

MIT or Apache licenses would be ideal! I'd love to be able to use and contribute back to this project!

from js-objectdetect.

mtschirs avatar mtschirs commented on June 17, 2024

...just moved to the MIT license

from js-objectdetect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.