Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Examples LinkSVP 4: Use the movement detection implemented LinkIVE
background
See LinkSVP example of one of Beijing introduced.
LinkSVP Profile
See one of LinkSVP exampleLinkSVP
introduction.
Example achieve movement detection MotionDetect
The sample program demonstrates how to use LinkIVE be a relatively complete motion detection feature development.
Ready to work
- Refer to the user manual setup the development environment, compiler 3531D engineering, network boot configuration parameters.
- With HDMI output device (e.g. camera, a notebook, a set top box, etc.) access the HDMI-A Evaluation Board Interface
- The evaluation board monitor connected HDMI-OUT (1080P can support, default program output 1080P60).
- On power-up, enter the
/root/demo
directory - Run
MotionDetect
the program
operation result
Complete project
See the complete project: https://gitee.com/LinkPi/LinkSVP/tree/master/MotionDetect
The main source code
main.cpp
#include <QCoreApplication>
#include "Link.h"
#include "MotionDetect.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Link::init();
LinkObject *vi=Link::create("InputVi");
QVariantMap dataVi;
dataVi["interface"]="HDMI-A";
vi->start(dataVi);
MotionDetect *MD=new MotionDetect();
QVariantMap dataMD;
dataMD["framerate"]=4;
MD->start(dataMD);
LinkObject *vo=Link::create("OutputVo");
QVariantMap dataVo;
dataVo["type"]="hdmi";
vo->start(dataVo);
vi->linkV(MD)->linkV(vo);
return a.exec();
}
MotionDetect.cpp
#include "MotionDetect.h"
MotionDetect::MotionDetect(QObject *parent) : LinkFrame(parent)
{
data["framerate"]=4;
data["width"]=640;
data["height"]=360;
data["thresh"]=30;
data["area"]=800;
mem["pre"]=IVEMem(640,360);
mem["ccl"]=IVEMem(640,360);
}
void MotionDetect::oneFrame()
{
Sub(mem["in"],mem["pre"],mem["out"]);
thresh(mem["out"],mem["out"],data["thresh"].toInt());
erode(mem["out"],mem["out"],3);
dilate(mem["out"],mem["out"],5);
copy(mem["out"],mem["ccl"]);
wait();
QVariantList list=CCL(mem["ccl"],data["area"].toInt());
copy(mem["in"],mem["pre"]);
wait();
if(list.count()>0)
{
qDebug("######################################");
for(int i=0;i<list.count();i++)
{
qDebug()<<list[i];
}
}
}