示例#1
0
文件: debayer.py 项目: mridley/misc
def show_images(args):
    '''show all images'''
    global image, idx

    cv.NamedWindow('Bayer')
    if len(args) > 1:
        tbar = cv.CreateTrackbar('Image', 'Bayer', 0, len(args)-1, change_image)
    cv.SetMouseCallback('Bayer', mouse_event, None)

    idx = 0
    pgm = None
    while True:
        print(args[idx])
        (image, pgm) = change_image(idx)
        oldidx = idx
        newidx = util.key_menu(oldidx, len(args), image,
                               '%s.png' % args[idx][:-4],
                               pgm=pgm)
        idx += (newidx - oldidx)
        cv.SetTrackbarPos('Image', 'Bayer', idx)
    cv.DestroyWindow('Bayer')
示例#2
0
文件: highest.py 项目: weihli/cuav
    maxpos = (maxpoint % 1280, maxpoint / 1280)
    color_img = cv.CreateImage((1280, 960), 16, 3)

    cv.CvtColor(pgm.img, color_img, cv.CV_GRAY2RGB)

    overlay = cv.CreateImage((1280, 960), 16, 3)
    cv.SetZero(overlay)

    cv.Circle(overlay, maxpos, 10, cv.CV_RGB(65535, 0, 0))

    cv.AddWeighted(color_img, 1.0, overlay, 1.0, 0.5, color_img)

    cv.ShowImage('Highest', color_img)
    cv.SetMouseCallback('Highest', mouse_event, pgm)

    return color_img


cv.NamedWindow('Highest')

i = 0
while True:
    print(args[i])
    image = circle_highest(args[i])
    i = util.key_menu(i, len(args), image, 'highest.png')

for f in args:
    circle_highest(f)

cv.DestroyWindow('Highest')
示例#3
0
文件: edges.py 项目: 1ee7/cuav
    # convert to 8 bit
    img8 = cv.CreateImage((1280,960), 8, 1)
    cv.ConvertScale(pgm.img, img8, scale=1.0/256)

    edge1 = cv.CreateImage((1280,960), 8, 1)
    cv.Canny(img8, edge1, 250, 255, 5)

    edgecolor = cv.CreateImage((1280,960), 8, 3)
    edgecolor16 = cv.CreateImage((1280,960), 16, 3)
    cv.CvtColor(edge1, edgecolor, cv.CV_GRAY2RGB)
    cv.ConvertScale(edgecolor, edgecolor16, scale=256)

    color_img = cv.CreateImage((1280,960), 16, 3)
    cv.CvtColor(pgm.img, color_img, cv.CV_GRAY2RGB)

    cv.AddWeighted(color_img, 1.0, edgecolor16, 1.0, 0.5, color_img)

    cv.ShowImage('Edges', color_img)
    return color_img


cv.NamedWindow('Edges')

i = 0
while True:
    print(args[i])
    image = show_edges(args[i])
    i = util.key_menu(i, len(args), image, 'edges.png')

cv.DestroyWindow('Edges')
示例#4
0
文件: threshold.py 项目: 1ee7/cuav
def change_threshold(value):
    '''change displayed threshold'''
    global img_thresh, imgf, threshold
    threshold = value
    cv.Threshold(imgf, img_thresh, value/65536.0, 0, cv.CV_THRESH_TOZERO)
    cv.ShowImage('Threshold', img_thresh)
    return img_thresh

def show_threshold(filename):
    '''threshold an image'''
    global threshold, imgf
    pgm = util.PGM(filename)

    cv.ConvertScale(pgm.img, imgf, scale=1.0/65536)
    return change_threshold(threshold)

imgf = cv.CreateImage((1280,960), cv.IPL_DEPTH_32F, 1)
img_thresh = cv.CreateImage((1280,960), cv.IPL_DEPTH_32F, 1)
threshold = 0

cv.NamedWindow('Threshold')
cv.CreateTrackbar('Threshold', 'Threshold', 0, 65536, change_threshold)

i = 0
while True:
    print(args[i])
    image = show_threshold(args[i])
    i = util.key_menu(i, len(args), image, 'threshold.png')

cv.DestroyWindow('Threshold')
示例#5
0
文件: edges.py 项目: weihli/cuav
    # convert to 8 bit
    img8 = cv.CreateImage((1280, 960), 8, 1)
    cv.ConvertScale(pgm.img, img8, scale=1.0 / 256)

    edge1 = cv.CreateImage((1280, 960), 8, 1)
    cv.Canny(img8, edge1, 250, 255, 5)

    edgecolor = cv.CreateImage((1280, 960), 8, 3)
    edgecolor16 = cv.CreateImage((1280, 960), 16, 3)
    cv.CvtColor(edge1, edgecolor, cv.CV_GRAY2RGB)
    cv.ConvertScale(edgecolor, edgecolor16, scale=256)

    color_img = cv.CreateImage((1280, 960), 16, 3)
    cv.CvtColor(pgm.img, color_img, cv.CV_GRAY2RGB)

    cv.AddWeighted(color_img, 1.0, edgecolor16, 1.0, 0.5, color_img)

    cv.ShowImage('Edges', color_img)
    return color_img


cv.NamedWindow('Edges')

i = 0
while True:
    print(args[i])
    image = show_edges(args[i])
    i = util.key_menu(i, len(args), image, 'edges.png')

cv.DestroyWindow('Edges')
示例#6
0
文件: markimages.py 项目: 1ee7/cuav
        print("[%u, %u] : %u" % (x, y, pgm.img[y, x]))
    if flags & cv.CV_EVENT_FLAG_RBUTTON:
        f = open('joe.txt', mode='a')
        f.write('%s %u %u\n' % (args[idx], x, y))
        f.close()
        print("Joe at %u,%u of %s" % (x, y, args[idx]))

def change_image(i):
    '''show image idx'''
    global idx, pgm
    idx = i
    pgm = util.PGM(args[idx])
    cv.ShowImage('CanberraUAV', pgm.img)

cv.NamedWindow('CanberraUAV')
if len(args) > 1:
    tbar = cv.CreateTrackbar('Image', 'CanberraUAV', 0, len(args)-1, change_image)
cv.SetMouseCallback('CanberraUAV', mouse_event, None)

idx = 0
pgm = None
while True:
    print(args[idx])
    change_image(idx)
    oldidx = idx
    newidx = util.key_menu(oldidx, len(args), None, None)
    idx += (newidx - oldidx)
    cv.SetTrackbarPos('Image', 'CanberraUAV', idx)

cv.DestroyWindow('CanberraUAV')
示例#7
0
        f.write('%s %u %u\n' % (args[idx], x, y))
        f.close()
        print("Joe at %u,%u of %s" % (x, y, args[idx]))


def change_image(i):
    '''show image idx'''
    global idx, pgm
    idx = i
    pgm = util.PGM(args[idx])
    cv.ShowImage('CanberraUAV', pgm.img)


cv.NamedWindow('CanberraUAV')
if len(args) > 1:
    tbar = cv.CreateTrackbar('Image', 'CanberraUAV', 0,
                             len(args) - 1, change_image)
cv.SetMouseCallback('CanberraUAV', mouse_event, None)

idx = 0
pgm = None
while True:
    print(args[idx])
    change_image(idx)
    oldidx = idx
    newidx = util.key_menu(oldidx, len(args), None, None)
    idx += (newidx - oldidx)
    cv.SetTrackbarPos('Image', 'CanberraUAV', idx)

cv.DestroyWindow('CanberraUAV')
示例#8
0
文件: highest.py 项目: 1ee7/cuav
    maxpos = (maxpoint%1280, maxpoint/1280)
    color_img = cv.CreateImage((1280,960), 16, 3)

    cv.CvtColor(pgm.img, color_img, cv.CV_GRAY2RGB)

    overlay = cv.CreateImage((1280,960), 16, 3)
    cv.SetZero(overlay)

    cv.Circle(overlay, maxpos, 10, cv.CV_RGB(65535, 0, 0))

    cv.AddWeighted(color_img, 1.0, overlay, 1.0, 0.5, color_img)

    cv.ShowImage('Highest', color_img)
    cv.SetMouseCallback('Highest', mouse_event, pgm)

    return color_img


cv.NamedWindow('Highest')

i = 0
while True:
    print(args[i])
    image = circle_highest(args[i])
    i = util.key_menu(i, len(args), image, 'highest.png')

for f in args:
    circle_highest(f)

cv.DestroyWindow('Highest')
示例#9
0
文件: threshold.py 项目: weihli/cuav
    global img_thresh, imgf, threshold
    threshold = value
    cv.Threshold(imgf, img_thresh, value / 65536.0, 0, cv.CV_THRESH_TOZERO)
    cv.ShowImage('Threshold', img_thresh)
    return img_thresh


def show_threshold(filename):
    '''threshold an image'''
    global threshold, imgf
    pgm = util.PGM(filename)

    cv.ConvertScale(pgm.img, imgf, scale=1.0 / 65536)
    return change_threshold(threshold)


imgf = cv.CreateImage((1280, 960), cv.IPL_DEPTH_32F, 1)
img_thresh = cv.CreateImage((1280, 960), cv.IPL_DEPTH_32F, 1)
threshold = 0

cv.NamedWindow('Threshold')
cv.CreateTrackbar('Threshold', 'Threshold', 0, 65536, change_threshold)

i = 0
while True:
    print(args[i])
    image = show_threshold(args[i])
    i = util.key_menu(i, len(args), image, 'threshold.png')

cv.DestroyWindow('Threshold')