def processSurf(img, imageId): data = 325 pdata = cPickle.dumps(data, cPickle.HIGHEST_PROTOCOL) pdatabin = sqlite3.Binary(pdata) kpDes, numDescriptors = surf.calc_surf_blend(img) kpDes_pickle = cPickle.dumps(kpDes, cPickle.HIGHEST_PROTOCOL) kpDes_bin = sqlite3.Binary(kpDes_pickle) print cPickle.HIGHEST_PROTOCOL print pdata print pdatabin c.execute("""INSERT INTO table1 (data) VALUES (?)""", (kpDes_bin, ))
def processSurf(img,imageId,c,conn): kpDes, numDescriptors = surf.calc_surf_blend(img) kpDes_pickle = pickle.dumps(kpDes, pickle.HIGHEST_PROTOCOL) kpDes_bin = sqlite3.Binary(kpDes_pickle) cmd = 'INSERT INTO {tn}(imageId, numDescriptors, descriptors) VALUES((SELECT imageId from images WHERE imageId="{iId}"), {numDes}, ?)'.format(tn=table_name,iId=imageId,numDes=numDescriptors) #print cmd try: c.execute(cmd,(kpDes_bin,)) conn.commit() except sqlite3.IntegrityError: print('ERROR: ID already exists in PRIMARY KEY column {}'.format(imageId))
def processSurf(img,imageId): data = 325 pdata = cPickle.dumps(data, cPickle.HIGHEST_PROTOCOL) pdatabin = sqlite3.Binary(pdata) kpDes, numDescriptors = surf.calc_surf_blend(img) kpDes_pickle = cPickle.dumps(kpDes, cPickle.HIGHEST_PROTOCOL) kpDes_bin = sqlite3.Binary(kpDes_pickle) print cPickle.HIGHEST_PROTOCOL print pdata print pdatabin c.execute("""INSERT INTO table1 (data) VALUES (?)""",(kpDes_bin,))
def processSurf(img, imageId, c, conn): kpDes, numDescriptors = surf.calc_surf_blend(img) kpDes_pickle = pickle.dumps(kpDes, pickle.HIGHEST_PROTOCOL) kpDes_bin = sqlite3.Binary(kpDes_pickle) cmd = 'INSERT INTO {tn}(imageId, numDescriptors, descriptors) VALUES((SELECT imageId from images WHERE imageId="{iId}"), {numDes}, ?)'.format( tn=table_name, iId=imageId, numDes=numDescriptors) #print cmd try: c.execute(cmd, (kpDes_bin, )) conn.commit() except sqlite3.IntegrityError: print('ERROR: ID already exists in PRIMARY KEY column {}'.format( imageId))