# Read the list of test image files
        source_dir = dir_prefix + image_directory + '/'
        img_files = glob.glob(source_dir + '*.jpg')
        
        filenumber = 1
        nfiles = len(img_files)
        for testfile in img_files:
            print '%s (%d/%d)' % (testfile,filenumber,nfiles)
            filenumber += 1

            ###################################################################
            # Change the following line to use a different detection routine. #
            ###################################################################
            
            im = cv.imread(testfile)#fla - added this 
            matchingcoords = cascadedetect.detect(im)#originally detect(testfile) which was str not im
            
            boundingboxes = getboundingboxes(testfile)
            '''if boundingboxes == []:
                break'''
            #im = cv.LoadImage(testfile)#fla - void in opencv 3.0. Above i used imread
                        
            if show_images:
                for match in matchingcoords:
                    xcentre = match[0]
                    ycentre = match[1]
                    cv.circle( im, (xcentre,ycentre), 10, [0,0,255] )
                
                for bb in boundingboxes:
                    cv.rectangle(im,(bb[0],bb[2]),(bb[1],bb[3]), [255, 255, 255], 1)
                
import os
import copy
import sys
import cascadedetect
import boosteddetect


if __name__=='__main__':
    imagefilename = sys.argv[1]
    xstep = int(sys.argv[2])
    ystep = int(sys.argv[3])
    size = int(sys.argv[4])
    detectortype = sys.argv[5] 

    if detectortype=='cascade':
        matchingcoords = cascadedetect.detect(imagefilename)
    else:
        patchscores = boosteddetect.detect(imagefilename,featuretype=detectortype,returnpatchscores=True,paramsdir='../../../data/params/')

    im = cv.LoadImage(imagefilename)

    # Scan through patch locations in the image
    patchidx = 0
    width = im.width
    height = im.height
    x = xstep
    y = ystep
    while y<height:
        x = xstep;
        while (x<width):
            # Test whether a square at this point includes the center of a detected object
示例#3
0
    for image_directory in test_directories:

        # Read the list of test image files
        source_dir = dir_prefix + image_directory + '/'
        img_files = glob.glob(source_dir + '*.jpg')

        filenumber = 1
        nfiles = len(img_files)
        for testfile in img_files:
            print '%s (%d/%d)' % (testfile, filenumber, nfiles)
            filenumber += 1

            ###################################################################
            # Change the following line to use a different detection routine. #
            ###################################################################
            matchingcoords = cascadedetect.detect(testfile)

            boundingboxes = getboundingboxes(testfile)
            im = cv.LoadImage(testfile)

            if show_images:
                for match in matchingcoords:
                    xcentre = match[0]
                    ycentre = match[1]
                    cv.Circle(im, (xcentre, ycentre), 10, [0, 0, 255])

                for bb in boundingboxes:
                    cv.Rectangle(im, (bb[0], bb[2]), (bb[1], bb[3]),
                                 [255, 255, 255], 1)

            TPim = FPim = FNim = 0
示例#4
0
        # Read the list of test image files
        source_dir = dir_prefix + image_directory + '/'
        img_files = glob.glob(source_dir + '*.jpg')

        filenumber = 1
        nfiles = len(img_files)
        for testfile in img_files:
            print '%s (%d/%d)' % (testfile, filenumber, nfiles)
            filenumber += 1

            ###################################################################
            # Change the following line to use a different detection routine. #
            ###################################################################

            im = cv.imread(testfile)  #fla - added this
            matchingcoords = cascadedetect.detect(
                im)  #originally detect(testfile) which was str not im

            boundingboxes = getboundingboxes(testfile)
            '''if boundingboxes == []:
                break'''
            #im = cv.LoadImage(testfile)#fla - void in opencv 3.0. Above i used imread

            if show_images:
                for match in matchingcoords:
                    xcentre = match[0]
                    ycentre = match[1]
                    cv.circle(im, (xcentre, ycentre), 10, [0, 0, 255])

                for bb in boundingboxes:
                    cv.rectangle(im, (bb[0], bb[2]), (bb[1], bb[3]),
                                 [255, 255, 255], 1)
    for image_directory in test_directories:
        
        # Read the list of test image files
        source_dir = dir_prefix + image_directory + '/'
        img_files = glob.glob(source_dir + '*.jpg')
        
        filenumber = 1
        nfiles = len(img_files)
        for testfile in img_files:
            print '%s (%d/%d)' % (testfile,filenumber,nfiles)
            filenumber += 1

            ###################################################################
            # Change the following line to use a different detection routine. #
            ###################################################################
            matchingcoords = cascadedetect.detect(testfile)
            
            boundingboxes = getboundingboxes(testfile)
            im = cv.LoadImage(testfile)
                        
            if show_images:
                for match in matchingcoords:
                    xcentre = match[0]
                    ycentre = match[1]
                    cv.Circle( im, (xcentre,ycentre), 10, [0,0,255] )
                
                for bb in boundingboxes:
                    cv.Rectangle(im,(bb[0],bb[2]),(bb[1],bb[3]), [255, 255, 255], 1)
                
            TPim = FPim = FNim = 0
            
示例#6
0
from lxml import etree
import cv
import os
import copy
import sys
import cascadedetect


if __name__=='__main__':

    imagefilename = sys.argv[1]
    xstep = int(sys.argv[2])
    ystep = int(sys.argv[3])
    size = int(sys.argv[4])

    matchingcoords = cascadedetect.detect(imagefilename,cascadefile='../../data/cascade/cascade_HAAR2.xml',
                                          trainpatchsize=14,smallestobjectsize=45.0,scalefactor=1.1,minneighbours=1)         
    im = cv.LoadImage(imagefilename)

    # Scan through patch locations in the image
    width = im.width
    height = im.height
    x = xstep
    y = ystep
    while y<height:
        x = xstep;
        while (x<width):
            # Test whether a square at this point includes the center of a detected object
            objecthere = 0
            for c in matchingcoords:
                if (x-size/2 < c[0]) and (x+size/2 > c[0]) and (y-size/2 < c[1]) and (y+size/2 > c[1]):
                    objecthere = 1