def main(self, image_url,  mex_url = None, bisque_token=None, bq = None, args = None):
        #  Allow for testing by passing an alreay initialized session
        if bq is None:
            bq = BQSession().init_mex(mex_url, bisque_token)
        # Fetch the blob  links
        if not os.path.exists ('videos'):
            os.makedirs ('videos')
        video = fetch_blob(bq, image_url, 'videos')
        print "VIDEO file ", video
	 #pass arguments to MotionMeerkat scripts, located in MotionMeerkat/main.py	
	#Structure arguments
	#Format call string

        callargs = ["python MotionMeerkat/main.py", 
                    "--i", video.values()[0], 
                    "--threshT", args[0],
                    "--sub", args[1],
                    "--mogh", args[2],
                    "--mogv", args[3],
                    "--accA", args[4],
                    "--burn", args[5],
                    "--frameSET", 
                    "--frame_rate", "1",
                    "--makeV", "none",
                    "--fileD", "Output"]
	print "Calling ", " ".join(callargs)

	#run MotionMeerkat
	r =  call(" ".join(callargs), shell=True)
        if r != 0:
		bq.fail_mex ("Meerkat returned non-zero")
		#Post Results
	
	#get filename to get the destination of the csv to be posted
	fn=video.values()[0]
	fbs= os.path.basename(fn)
	head, tail = os.path.splitext(fbs)
	
	#post file
	frames_blob = bq.postblob(str("Output/" + head + "/Frames.csv"))
	
	#get file location from regex
	uri=re.search("uri=\"(.*?)\"", frames_blob).group(1)
	tags = [{ 'name': 'outputs','tag' : [{'name': 'frames_csv', 'type':'file', 'value':uri}]}]
	bq.finish_mex(tags = tags)
	sys.exit(0)
Exemple #2
0
root = 'http://bisque.ece.ucsb.edu'
user = '******'
pswd = 'Bisque1'
session = BQSession().init_local(user,
                                 pswd,
                                 bisque_root=root,
                                 create_mex=False)

# upload files
for f in files:
    print '\nuploading %s' % f['filename']
    filepath = os.path.join(img_home, f['filename'])
    resource = f['resource']

    # use import service to /import/transfer activating import service
    r = etree.XML(session.postblob(filepath, xml=resource)).find('./')

    if r is None or r.get('uri') is None:
        print 'Upload failed'
    else:
        print 'Uploaded ID: %s, URL: %s' % (r.get('resource_uniq'),
                                            r.get('uri'))
        f['url'] = r.get('uri')

# upload dataset
dataset = etree.Element('dataset', name=dataset_name)
for f in files:
    if 'url' not in f:
        continue
    v = etree.SubElement(dataset, 'value', type="object")
    v.text = f['url']