IE不支持WebRTC,所以没有办法通过JS接口在浏览器中直接访问USB摄像头。解决的方法就是通过本地启动一个服务去获取摄像头数据,然后发送到IE的web页面上,通过img元素不断刷新来显示,这个在上一篇文章中已经说过。这篇文章是基于上一篇里Node.js的代码,增加条形码扫描功能。
基于C/C++的Node.js条形码模块编译
C/C++的封装代码在https://github.com/Dynamsoft/nodejs-barcode。
用于解码的接口是decodeBufferAsync()
。以下是相关的C/C++代码:
void DecodeBufferAsync(const FunctionCallbackInfo<Value>& args) {
if (!createDBR()) {
return;}
Isolate* isolate = Isolate::GetCurrent();
Local<Context> context = isolate->GetCurrentContext();
// get arguments
unsigned char* buffer = (unsigned char*) node::Buffer::Data(args[0]); // file stream
int width = args[1]->Int32Value(context).ToChecked(); // image width
int height = args[2]->Int32Value(context).ToChecked(); // image height
int stride = args[3]->Int32Value(context).ToChecked(); // stride
int iFormat = args[4]->Int32Value(context).ToChecked(); // barcode types
Local<Function> cb = Local<