Corner Harris

该算法实现了用于检测关键点和推断图像特征的Harris关键点检测算子。

算子效果

输入图像参数输出图像
imageblockSize = 3
sensitivity = 0.04
kernelSize = 3
borderType = HB_VP_BORDER_REPLICATE
image

原理

计算过程如下:

dst(x,y)=det(A)ktrace(A)2dst(x,y)=det(A)-k*trace(A)^2

其中,dstdst 为输出图片。

trace(A)=AGx2+AGy2trace(A)=\displaystyle\sum_A {G_x}^2+\displaystyle\sum_A {G_y}^2

det(A)=AGx2AGy2(AGxGy)2det(A)=\displaystyle\sum_A{{G_x}^2}\displaystyle\sum_A{{G_y}^2}-(\displaystyle\sum_A{G_x G_y})^2

其中,GxG_x 为x方向上的sobel卷积,GyG_y 为y方向上的sobel卷积,AA 为卷积窗口。

API接口

int32_t hbVPCornerHarris(hbUCPTaskHandle_t *taskHandle, hbVPImage *dstImg, hbVPImage const *srcImg, hbVPCornerHarrisParam const *cornerHarrisParam);

详细接口信息请查看 hbVPCornerHarris

使用方法

// Include the header #include "hobot/hb_ucp.h" #include "hobot/vp/hb_vp.h" #include "hobot/vp/hb_vp_corner_harris.h" // init Image, allocate memory for image data hbUCPSysMem src_mem; hbUCPSysMem src_mem; hbUCPMallocCached(&src_mem, src_stride * src_height, 0); hbVPImage src_img{HB_VP_IMAGE_FORMAT_Y, HB_VP_IMAGE_TYPE_U8C1, src_width, src_height, src_stride, src_mem.virAddr, src_mem.phyAddr, nullptr, 0, 0}; hbUCPSysMem dst_mem; hbUCPMallocCached(&dst_mem, dst_stride * dst_height, 0); hbVPImage dst_img{HB_VP_IMAGE_FORMAT_Y, HB_VP_IMAGE_TYPE_S32C1, dst_width, dst_height, dst_stride, dst_mem.virAddr, dst_mem.phyAddr, nullptr, 0, 0}; // init param hbVPCornerHarrisParam corner_harris_param; corner_harris_param.blockSize = 3; corner_harris_param.sensitivity = 0.04; corner_harris_param.kernelSize = 3; corner_harris_param.borderType = 1; // init task handle and schedule param hbUCPTaskHandle_t task_handle{nullptr}; hbUCPSchedParam sched_param; HB_UCP_INITIALIZE_SCHED_PARAM(&sched_param); sched_param.backend = HB_UCP_DSP_CORE_0; // create task hbVPCornerHarris(&task_handle, &dst_img, &src_img, &corner_harris_param); // submit task hbUCPSubmitTask(task_handle, &sched_param); // wait for task done hbUCPWaitTaskDone(task_handle, 0); // release task handle hbUCPReleaseTask(task_handle); // release memory hbUCPFree(&src_mem); hbUCPFree(&dst_mem);