halcon转c++后,region是否为空的判定

使用面积来判定region是否为空。不要用cout_obj,为空也是1。

#include<HalconCpp.h>
using namespace HalconCpp;

int main()
{
    HObject img,region;
    HTuple area;
    GenImageConst(&img, "byte", 512, 512);    //灰度为0的单通道图
    Threshold(img, &region, 1, 255);        //没有分割出区域
    AreaCenter(region, &area, NULL, NULL);
    if (area[0].L()>0)
    {
        //region不为空
    }
    return 0;
}

 

posted @ 2024-07-21 16:35  夕西行  阅读(6)  评论(0编辑  收藏  举报