def get(self, id, person_id): '''Returns bvh-Files by person index (counting from 0) for a job by id''' args = filter_parser.parse_args(strict=True) result = model.get_result_by_id(id) if result is None: return 404 if result.result_code is not model.ResultCode.success: return 202 if person_id > result.max_people or person_id < 1: raise BadRequest("Person %d does not exist - Max index is %d." % (person_id, result.max_people)) path = os.path.join(Config.CACHE_DIR, str(result.id), Config.RESULT_DIR) job = model.get_job_by_id(id) myfile = "%s by %s (%d-%d).bvh" % (job.name, job.user.username, person_id, result.max_people) if args['border'] is not None and args['u0'] is not None: filter_bvh(result.id, args['border'], args['u0'], person_id) return send_from_directory( path, Config.OUTPUT_BVH_FILE_FILTERED_DYNAMIC_NUMBERED % person_id, as_attachment=True, attachment_filename=myfile, mimetype="application/octet-stream") return send_from_directory(path, Config.OUTPUT_BVH_FILE_RAW_NUMBERED % person_id, as_attachment=True, attachment_filename=myfile, mimetype="application/octet-stream")
def get(self, id): '''render interactive 3d scene for result with motion capturing data for a job by id''' args = filter_parser.parse_args(strict=True) headers = {'Content-Type': 'text/html'} num_people = model.get_result_by_id(id).max_people urls = [] if args['border'] is None or args['u0'] is None: for i in range(1, num_people + 1): urls.append( url_for('api.results_result_bvh_file_for_person', id=id, person_id=i)) else: for i in range(1, num_people + 1): #ResultBvhFileForPersonFiltered urls.append( url_for('api.results_result_bvh_file_for_person', id=id, person_id=i, border=args['border'], u0=args['u0'])) print(urls) return make_response( render_template('bvh_import/index.html', title=model.get_job_by_id(id).name, url_array=urls), 200, headers)
def get(self, id): '''Get a job by a given id''' job = model.get_job_by_id(id) check_auth(job, auth.get_auth()) if job is None: abort(404, "The resource was not found.") return job
def get(self, id): '''Get the Source video for a Job by an id''' # check if job exists job = model.get_job_by_id(id) check_auth(job, auth.get_auth()) directory = os.path.join(Config.CACHE_DIR, str(job.id)) # check if result is succesful try: return send_from_directory(directory, Config.SOURCE_VIDEO_FILE, as_attachment=True, mimetype="video/mp4") except Exception as e: abort(404)
def get(self, id, person_id): '''render interactive 3d scene for specific person for result with motion capturing data for a job by id''' headers = {'Content-Type': 'text/html'} args = filter_parser.parse_args(strict=True) url = [ url_for('api.results_result_bvh_file_for_person', id=id, person_id=person_id, border=args['border'], u0=args['u0']) ] return make_response( render_template('bvh_import/index.html', url_array=url, title=model.get_job_by_id(id).name), 200, headers)
def get(self, id): '''get result video for a job by id (visualization of joints) -- replaced by "results/{id}/render_html"''' check_auth(model.get_job_by_id(id), auth.get_auth()) result = model.get_result_by_id(id) if result is None: return 404 if result.result_code is not model.ResultCode.success: return 202 path = os.path.join(Config.CACHE_DIR, str(result.id), Config.RESULT_DIR) return send_from_directory(path, Config.OUTPUT_VIDEO_FILE, as_attachment=True, attachment_filename=str(result.id) + ".mp4", mimetype="video/mp4")
def get(self, id): '''Returns bvh-Files for a result as zip (or as .bvh, if only one person was tracked) for a job by id''' result = model.get_result_by_id(id) job = model.get_job_by_id(id) if result is None: return 404 if result.result_code is not model.ResultCode.success: return 202 path = os.path.join(Config.CACHE_DIR, str(result.id), Config.RESULT_DIR) # return 1 person if result.max_people == 1: myfile = "%s by %s (%d-%d).bvh" % (job.name, job.user.username, 1, result.max_people) return send_from_directory(path, Config.OUTPUT_BVH_FILE_RAW_NUMBERED % 1, as_attachment=True, attachment_filename=myfile, mimetype="application/octet-stream") return serve_zip(job, result)
def put(self, id): '''Upload a video for a specific job, it will automatically enqueue in the analysis''' args = parsers.upload_parser.parse_args() # check if the sent file is actually a video. if not args['video'].mimetype == 'video/mp4': abort(415) job = model.get_job_by_id(id) check_auth(job, auth.get_auth()) if job is None: abort(404) # if the video has been uploaded already, it cannot be uploaded again elif job.video_uploaded is True: abort(409, "Video has been uploaded already") with Connection(conn): q = Queue() q.enqueue(convert_xnect, my_job_id=job.id, video=args['video'].read()) job.video_uploaded = True model.db.session.commit() return job
def delete(self, id): '''delete a posted job by given ID''' check_auth(model.get_job_by_id(id), auth.get_auth()) return model.set_job_private(id, g.user.id)
def post(self, id): '''Post a job by given id''' check_auth(model.get_job_by_id(id), auth.get_auth()) return model.set_job_public(id, g.user.id)
def get(self, id): '''get results for a job by id''' check_auth(model.get_job_by_id(id), auth.get_auth()) return model.get_result_by_id(id)
def get(self, id): '''Get a Status for a Job by an id''' check_auth(model.get_job_by_id(id), auth.get_auth()) return get_job_status(id)