00001
00002
00003
00004
00005
00006
00007
00008 from fulguro import *
00009 from fulguro.flgrrtcapture import *
00010
00011 size_x = 640
00012 size_y = 480
00013
00014 cam0 = FLGR_RtCapture2D("/dev/video0")
00015 cam0.set_palette("YV12")
00016 cam0.set_size(size_x,size_y)
00017
00018 imin = FLGR_Data2D(size_y,size_x,1,FLGR_UINT8)
00019 immir = FLGR_Data2D(imin)
00020 imtmp1 = FLGR_Data2D(imin)
00021 imtmp2 = FLGR_Data2D(imin)
00022 imout = FLGR_Data2D(imin)
00023
00024 nhb = FLGR_Data2D(9,9,imin.spp,imin.type,FLGR_RECT,FLGR_8_CONNEX)
00025 nhb2 = FLGR_Data2D(1,9,imin.spp,imin.type,FLGR_RECT,FLGR_8_CONNEX)
00026 nhb3 = FLGR_Data2D(9,9,imin.spp,imin.type,FLGR_RECT,FLGR_8_CONNEX)
00027 nhb4 = FLGR_Data2D(9,1,imin.spp,imin.type,FLGR_RECT,FLGR_8_CONNEX)
00028
00029 scr0 = flgr2d_rtview_create(immir, 1, 2)
00030
00031 for i in range(1000):
00032
00033 flgr2d_rtcapture_gray_image(imin, cam0)
00034 flgr2d_copy(immir,imin)
00035
00036
00037 flgr2d_open_tophat(imtmp1,immir,nhb)
00038 flgr2d_close_tophat(imtmp2,immir,nhb)
00039
00040 flgr2d_arith_inf(imout,imtmp1,imtmp2)
00041 flgr2d_replace(imout,imout,'>=',20,255,0)
00042
00043 flgr2d_close(imtmp1,imout,nhb2)
00044 flgr2d_open(imout,imtmp1,nhb2)
00045
00046 flgr2d_dilate(imtmp1,imout,nhb3)
00047 flgr2d_dilate(imout,imtmp1,nhb3)
00048 flgr2d_dilate(imtmp1,imout,nhb3)
00049 flgr2d_erode(imout,imtmp1,nhb3)
00050 flgr2d_erode(imtmp1,imout,nhb3)
00051 flgr2d_erode(imout,imtmp1,nhb3)
00052
00053 flgr2d_open(imtmp1,imout,nhb4)
00054
00055 flgr2d_replace(imout,imtmp1,'==',255,immir,0)
00056
00057 flgr2d_rtview_refresh(scr0, immir, 0, 0)
00058 flgr2d_rtview_refresh(scr0, imout, 0, 1)
00059
00060