|
具体代码如下:
- * 初始化窗口
- dev_update_off ()
- read_image (Image1, 'bicycle/bicycle_01')
- * 缩放图像--缩小一倍
- ZoomFactor := 0.5
- zoom_image_factor (Image1, Image1, ZoomFactor, ZoomFactor, 'constant')
- dev_close_window ()
- dev_open_window_fit_image (Image1, 0, 0, -1, -1, WindowHandle)
- * 显示区域的轮廓
- dev_set_draw ('margin')
- *
- * 产生监控区域,门禁外所在区域
- gen_contour_polygon_xld (ROI, [0,0,283,348,479,479] * ZoomFactor, [0,379,379,434,639,0] * ZoomFactor)
- gen_region_contour_xld (ROI, RegionROI, 'filled')
- reduce_domain (Image1, RegionROI, Image1ROI)
- * 主循环
- for I := 2 to 9 by 1
- read_image (Image2, 'bicycle/bicycle_0' + I)
- * 缩放图像--缩小一倍
- zoom_image_factor (Image2, Image2, ZoomFactor, ZoomFactor, 'constant')
- reduce_domain (Image2, RegionROI, Image2ROI)
- * 光流矢量场模型
- optical_flow_mg (Image1ROI, Image2ROI, VectorField, 'fdrig', 0.8, 1, 10, 5, ['default_parameters','warp_zoom_factor'], ['fast',0.8])
- vector_field_length (VectorField, LengthImage, 'squared_length')
- *
- * 在监控的区域分割目标
- min_max_gray (RegionROI, LengthImage, 0.1, Min, Max, Range)
- dev_display (Image2)
- if (Max > 2)
- threshold (LengthImage, RegionMovement, 2, Max)
- connection (RegionMovement, ConnectedRegions)
- * 选择最大的目标区域
- select_shape_std (ConnectedRegions, RegionMovement, 'max_area', 70)
- area_center (RegionMovement, Area, RCenterNew, CCenterNew)
- if (Area > 0)
- * 转化为凸多边形
- shape_trans (RegionMovement, ConvexHullregion, 'convex')
- intersection (RegionROI, ConvexHullregion, RegionMovementInROI)
- reduce_domain (VectorField, ConvexHullregion, VectorReduced)
- vector_field_to_real (VectorReduced, Row, Column)
- *
- * 估计目标运动的方向和速度
- intensity (RegionMovementInROI, Row, MeanRow, Deviation)
- intensity (RegionMovementInROI, Column, MeanColumn, Deviation1)
- *
- * 显示结果
- dev_set_line_width (1)
- dev_set_color ('yellow')
- dev_display (VectorReduced)
- * Display region of interest
- dev_set_line_width (3)
- dev_set_color ('magenta')
- dev_display (RegionROI)
- * 显示运动的目标
- dev_set_color ('green')
- dev_display (RegionMovementInROI)
- gen_arrow_contour_xld (Arrow, RCenterNew, CCenterNew, RCenterNew + MeanRow, CCenterNew + MeanColumn, 10, 10)
- dev_display (Arrow)
- endif
- endif
- *
- copy_obj (Image2ROI, Image1ROI, 1, 1)
- endfor
复制代码 参考:【1】基于光流法的运动目标检测
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|