Comments (7)
I'd be interested in that too. I also tried HAAR.js, but as @ludovicpages said: the output is different. And HAAR.js does not work with newer XML cascade files (generated by opencv_traincascade
, instead of the deprecated opencv_haartraining
).
from js-objectdetect.
I have what you need, check the following python code:
import xml.etree.ElementTree as ET
import sys
name = sys.argv[1]
tilted = False
size = "0,0"
tree = ET.parse('%s.xml' % name)
sys.stdout.write('var %s = {complexClassifiers:[' % name)
root = tree.getroot()
for n in root:
size = n.find('size').text.replace(' ', ',')
stages = n.find('stages')
ccs = ''
for s in stages:
sys.stdout.write('%s{simpleClassifiers:[' % (ccs))
trees = s.find('trees')
scs = ''
for t2 in trees:
sys.stdout.write('%s{features:[' % scs)
scs = ','
for t in t2:
feature = t.find('feature')
scf = ''
for r in feature.find('rects'):
sys.stdout.write('%s[%s]' % (scf, r.text.replace(' ', ',')))
scf = ','
tilted = tilted | (feature.find('tilted').text == '1')
threshold = t.find('threshold').text
right_val = t.find('right_val').text
left_val = t.find('left_val').text
sys.stdout.write('],threshold:%s,right_val:%s,left_val:%s}' % (threshold, right_val, left_val))
sys.stdout.write(']}')
ccs = ','
sys.stdout.write('],size:[%s],tilted:%s};\n' % (size, 'true' if tilted else 'false'))
sys.stdout.flush()
from js-objectdetect.
Thanks a lot for this @robertonr!
from js-objectdetect.
Does anyone have an idea if it's possible to convert the newer classifier formats, produced by opencv_traincascade
as opposed to opencv_haartraining
, to JavaScript and get it to work with this library?
from js-objectdetect.
@robertonr: Thanks for sharing your code!
@mrnugget: This library only handles stump-based cascaded. As long as opencv_traincascade can be configured to produce those, they should be compatible (probably with minor adaptions).
from js-objectdetect.
Here is a custom script to convert the new OpenCV xml format haarcascades produced by opencv_traincascade
: https://gist.github.com/mtschirs/df8d8dc5ff56cc7187b1
from js-objectdetect.
how i can convert my haarcascade in opencv 2.4 version with a similar python code? :( thanks
from js-objectdetect.
Related Issues (20)
- Objectdetect not working at all
- Custom classifier not working. HOT 1
- License HOT 1
- objectdetect.mouth.js HOT 1
- neck detection HOT 1
- not working after custom style change HOT 1
- False positives HOT 1
- Face detection with Pre-recorded video stream HOT 1
- Measuring activity using js-objectdetect
- Mouth/smile detector not working? HOT 8
- hand gesture sdk HOT 2
- noise detections > real detections HOT 12
- hand detection - with rotated hand HOT 4
- [Enhancement] Add package.json
- Mismatch between gh-pages & master files
- Create a new classifier HOT 2
- Consider adding library size to performance comparison
- No Documentation of JSDoc found HOT 1
- Tracking slow in FireFox only
- WebRTC not available HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-objectdetect.