示例#1
0
def main():
    """ Run all tests """
    from os.path import expanduser, join
    from os import listdir
    
    # Load test images
    im_directory = expanduser("~/Downloads")
    im_paths = map(
        lambda name: join(im_directory, name),
        filter(
            lambda name: name.lower().endswith('jpg'),
            listdir(im_directory)))
    
    # Load bit-hashing functions
    BitSampling.readHashFunctions()
    #readable_values(im_paths)
    json_encoded_values(im_paths)
示例#2
0
def test_JCD(im, silence=False):
    """ Testing: Joint Color Descriptor (JCD) """
    if not silence:
        print ""
        print "JCD:"
    jcd = JCD()
    jcd.extract(im)
    return (
        "n/a", #jcd.getStringRepresentation()
        Base64.encodeBase64String(
            jcd.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                jcd.getDoubleHistogram())))
示例#3
0
def test_PHOG(im, silence=False):
    """ Testing: Pyramidal Histogram of Gradient (PHOG) Descriptor """
    if not silence:
        print ""
        print "PHOG:"
    phog = PHOG()
    phog.extract(im)
    return (
        "n/a", # phog.getStringRepresentation()
        Base64.encodeBase64String(
            phog.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                phog.getDoubleHistogram())))
示例#4
0
def test_edge_histogram(im, silence=False):
    """ Testing: edge histogram """
    if not silence:
        print ""
        print "Edge Histogram:"
    edgehist = EdgeHistogram()
    edgehist.extract(im)
    return (
        edgehist.getStringRepresentation(),
        Base64.encodeBase64String(
            edgehist.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                edgehist.getDoubleHistogram())))
示例#5
0
def test_color_layout(im, silence=False):
    """ Testing: color layout """
    if not silence:
        print ""
        print "Color Layout:"
    colorlay = ColorLayout()
    colorlay.extract(im)
    return (
        colorlay.getStringRepresentation(),
        Base64.encodeBase64String(
            colorlay.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                colorlay.getDoubleHistogram())))
示例#6
0
def test_opponent_histogram(im, silence=False):
    """ Testing: opponent histogram """
    # sb.append(arrayToString(BitSampling.generateHashes(feature.getDoubleHistogram())));
    if not silence:
        print ""
        print "Opponent Histogram:"
    opphist = OpponentHistogram()
    opphist.extract(im)
    return (
        opphist.getStringRepresentation(),
        Base64.encodeBase64String(
            opphist.getByteArrayRepresentation()),
        ParallelSolrIndexer.arrayToString(
            BitSampling.generateHashes(
                opphist.getDoubleHistogram())))