Image processing using Native Client. The goal of this project is to use the C++ OpenCV image processing library to do realtime image processing of the webcam feed.
Rough plan for next few commits:
- Hidden HTML5 video element sourced from navigator.getUserMedia (webcam).
- Canvas element samples video every 20ms and draws on the canvas.
- Send canvas image as ArrayBuffer to Native Client.
- NaCl echoes image that has been received.
- Javascript puts echoed image to processed canvas.
- Start playing with OpenCV image processing.
- Use strategy pattern on the C++ side to register new image processors.
- Modify NaCl getVersion interface to return list of available processors.
- Use returned list of processors to populate js list selector.
- Get the Pulse Detection filter working.
- Get the Detecting Barcodes demo working.
- Simple cartoon filter.
- Face detection.
Try it out! - you may need to clear the cache to see any updates. To do this open Chrome Developer Tools (Ctrl-Shift-i or F12), then click and hold Reload, choose "Empty Cache and Hard Reload" from the popup menu. Popup menu may only appear if you have a cached page i.e. have previously visited.
UPDATED: Please see setup.txt in parent directory for a step by step setup on a new Ubuntu server.
There are a few steps needed to configure in order to use OpenCV with NaCl. Fortunately, once you become aware of the existence of NaCl Ports they are fairly straight forward.
-
Install Depo Tools.
-
Follow the Install guide for SDL, replacing sdl with opencv and choosing pnacl as the architecture to build.Seems like the original instructions have been deleted, and didn't cover which branch to use in any event. cd to the dir where you've checked out nacl_ports (for me ~/Work/ExternCode/nacl_ports/src ) with depotools then change to the branch that matches NACL_SDK_ROOTgit checkout pepper_40
NACL_ARCH=pnacl make opencvThe build itself took about 15 minutes on my Intel i3 dual core laptop.
-
Add the opencv libraries and zlib to the build arguments:
LDFLAGS := -L$(NACL_SDK_ROOT)/lib/pnacl/Release -lppapi_cpp -lppapi -lopencv_core -lz
NaCl updates on around the same release cycle as the Chrome browser. Chrome itself is backwards compatible but it's still a good idea to keep roughly up to date.
Here we assume that the NaCl SDK has been installed in NACL_ROOT (NACL_SDK_ROOT will be under this), and NaCl ports has been installed in PORTS_ROOT. On my machine these are ~/Work/ExternCode/nacl_sdk and ~/Work/ExternCode/nacl_ports respectively.
- Update NaCl SDK
- cd NACL_ROOT
- ./naclsdk update
- Update NACL_SDK_ROOT environment variable e.g. NACL_ROOT/pepper_41
- Update ports
- cd PORTS_ROOT
- cd src
- git checkout -b pepper_41 origin/pepper_41
- gclient sync
- (If that fails, cd .. vim .gclient and set managed=False)
BSD