OpenCV on node and more
A certification
Good news. I just received a certification from MongoDB University. There it is.
Cool! Right? I put in 7 weeks to complete this course. And here is the reference of the email:
Dear Tiger,
Congratulations! You have successfully completed M101JS: MongoDB for Node.js Developers with distinction. Your score puts you in the top 5% of all students who registered for the course. Great job!
WOW! Top 5%. Does it mean I am a top coder? I get myself calm and consider it a step to the upper level of my career life. Anyway, I’ll register the professional certification exam soon. Before that, I need to complete this blog.
OpenCV on node
Due to the new requirement of our project. (Yes, we did a reconstruction on our project.) We need to recognize the user’s face and crop it down to merge it into images sequence.
We’re working on Cocos Creator. Output target is Wechat game. We all know that Wechat works on mobile OS. Some of the native function and abilities are limited. Though the Wechat mini-app SDK provided some of the low-level api. But it’s doesn’t work when it comes to Wechat games.
So a better solution will be sending the image back to server, and let Master Bai,I mean, let the strong backend solve the problem. But before that, I need to walk through the path and make sure it works.
On Mac OS
Install opencv on mac os:
1 | brew install opencv@2 |
After that, check the status of opencv by:
1 | brew info opencv |
If you find anything wrong with a red-cross mark, try to install it with brew.
Replace homebrew’s mirror(If it is unbearably slow) by:
1 | export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles |
or change it in :
1 | echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles' >> ~/.bash_profile |
After opencv installed, we need to config pkg_config by
export PKG_CONFIG_PATH=/path/to/opencv/lib/pkgconfig
locate into the path of your npm project.
1 | npm i --save peterbraden/node-opencv |
After this, I think you already have a full config for opencv on Mac OS.
Here is how I test it:
1 | var cv = require("opencv"); |
Just the sample code from official site.
Install opencv on CentOS:
I found CentOS is more friendly than Ubuntu. My feeling is base on what I need though.
Vultr have a very straightforward blog about this:
https://www.vultr.com/docs/how-to-install-opencv-on-centos-7
Master BAI did a more elegant version by GO after 12 hours since I made this test. Master is Master.
Decode QRCode by Typescript in Cocos Creator.
The key problem here is not the lib I need to use. After 10 minutes googling I am sure jsqr is the one I need. The problem is how to provide UTF8ClampedArray as a parameter to jsqr function.
Here is how I beat it:
1 | showCameraFrame(){ |