基于 Node-red实现opencv边缘检测节点

基于 Node-red实现opencv边缘检测节点

最近在学习如何将opencv的一些用例以节点的形式加入到Node-red供用户使用,由于opencv边缘检测最简单,所以用其练手,来熟悉下开发流程。node-red上opencv节点基本框架三部分模块构成。

  • opencv边缘检测模块

  • 基于V8的js调用C++模块

  • nodejs边缘检测模块


下面是opencv边缘检测模块用例,共有三个函数分别供node-red图像输入节点、图像检测节点和图像输出节点调用,另外使用libuv定时器,用于在各node节点初始化后模拟图像输入,该模块最后将编译成静态库的形式使用。

#include <iostream>
#include <stdlib.h>
#include <unistd.h>
#include <opencv2/opencv.hpp>
#include <string>
#include <uv.h>
#include "cv_edge.h"

using namespace std;
using namespace cv;

//global function and parameter called by timer
static sendMsgCb imageInMsgCb;
static Mat deliverImg;

//the timer to send the mat of image
uv_timer_t imageInTimer;


void timer_cb(uv_timer_t *handle)
{
    printDebugMsg("C++ canny", "globalImg: %x", &deliverImg);
    imageInMsgCb((unsigned long)&deliverImg);
}

int imageInInit(char *path, sendMsgCb cb){
    int ret;
    if(cb != NULL){
        imageInMsgCb = cb;
    }

    if(path == NULL){
        printDebugMsg("C++ canny&#
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值