mobile CCTV,mobile surveillance,police body worn cameras
标题:
New openalpr_cloud.js
[打印本页]
author:
assistenzasoin
time:
2017-12-6 19:01
标题:
New openalpr_cloud.js
module.exports = function(RED){
var settings = RED.settings;
var OpenalprApi = require('openalpr_api');
函数OpenAlprCloudNode(n){
RED.nodes.createNode(this,n);
//加入所有国家(以逗号分隔的字符串)
this.countries = n.country.join();
this.secretKey = n.secretKey;
this.limit = n.limit;
this.recognizeVehicle = n.recognizeVehicle;
this.skipEmpty = n.skipEmpty;
this.passImage = n.passImage;
this.name = n.name;
var buffer = null;
var node = this;
var api = new OpenalprApi.DefaultApi();
node.on(“input”,function(msg){
//
如果(buffer!= null){
return;
}
node.status({fill:“blue”,shape:“dot”,text: “} Recognize”}};
buffer = msg.payload;
if(!Buffer.isBuffer(buffer)){
buffer = from(buffer);
}
var options = {};
options.state ='';
options.returnImage = 0;
options.prewarp ='';
if(node.recognizeVehicle){
options.recognizeVehicle = 1;
}
else {
options.recognizeVehicle = 0;
}
if(node.limit> 0){
//如果已经指定了限制,只传递'topn'数字
options.topn = this.limit;
}
// OpenAlpr-Api NodeJs模块包装V2 web服务(REST)。
api.recognizeBytes(buffer.toString(),node.secretKey,node.countries,options,function(error,body,response){
if(error || response.statusCode!= 200 || body == null){
node。状态({fill:“red”,shape:“ring”,text:“Error”});
}
else {
//克隆JSON正文,因为它似乎被swagger模块密封。事实上,当输出消息被Node-Red克隆时
(通过多条线发送),克隆对象没有值。由于JSON对象属性是不可配置的(他们
//没有setter),所以这些值不能被复制到它。通过创建一个克隆,我们可以“解决”这个问题。
body = JSON.parse(JSON.stringify(body));
var outputMsg = {};
outputMsg.payload = {};
outputMsg.payload.vehicles = [];
for(var i = 0; i <body.results.length; i ++){
var result = body.results
;
var vehicle = {};
vehicle.plate = result.candidates;
if(node.recognizeVehicle){
vehicle.brand = result.vehicle.make;
vehicle.model = result.vehicle.make_model;
vehicle.color = result.vehicle.color;
vehicle.type = result.vehicle.body_type;
}
vehicle.plate_coordinates = result.coordinates;
outputMsg.payload.vehicles.push(车辆);
}
outputMsg.credits = {};
outputMsg.credits.monthly_total = body.credits_monthly_total;
outputMsg.credits.monthly_used = body.credits_monthly_used;
outputMsg.credits.cost = body.credit_cost;
如果需要,只传递输入图像到输出消息
if(node.passImage){
outputMsg.image = buffer;
}
//如果找到了板块,只在输出端口发送一个msg,除非用户
指定列表允许为空
。if(outputMsg.payload.vehicles.length> 0 || node.skipEmpty == false){
node.send(outputMsg);
}
node.status({});
}
//允许处理下一个图像...
buffer = null;
});
});
this.on('close',function(){
//在(重新)部署的情况下,所有先前的处理都将被关闭
//允许下一个图像被处理...
buffer = null;
});
}
RED.nodes.registerType(“openalpr-cloud”,OpenAlprCloudNode);
}
file:///C:\Users\Assistenza\AppData\Roaming\Tencent\Users\3066273138\QQ\WinTemp\RichOle\7KBGCZTS$~9BKTF00%`E~YF.pngfile:///C:\Users\Assistenza\AppData\Roaming\Tencent\Users\3066273138\QQ\WinTemp\RichOle\7KBGCZTS$~9BKTF00%`E~YF.png
author:
hardfire
time:
2017-12-6 20:53
hi, what are you doing about?
author:
assistenzasoin
time:
2017-12-6 21:43
我输入了一个新的车牌阅读脚本,以包含在网络平台中
欢迎光临 mobile CCTV,mobile surveillance,police body worn cameras (http://bbs.besovideo.com:8067/)
Powered by Discuz! X3.2