Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLastGimbus committed Aug 28, 2023
2 parents bac3e92 + 6f775ef commit 5d95a2c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions roll_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def image(job_id):
job,
lambda: send_file(
io.BytesIO(job.return_value()['original_image']),
mimetype='image/jpeg',
download_name=f'{id}.jpg',
mimetype='image/webp',
download_name=f'{id}.webp',
etag=job.id,
last_modified=job.ended_at,
max_age=31536000,
Expand All @@ -181,8 +181,8 @@ def anal_image(job_id):
job,
lambda: send_file(
io.BytesIO(job.return_value()['kp_image']),
mimetype='image/jpeg',
download_name=f'{id}.jpg',
mimetype='image/webp',
download_name=f'{id}.webp',
etag=job.id,
last_modified=job.ended_at,
max_age=31536000,
Expand Down
9 changes: 5 additions & 4 deletions tasks/process_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ def process_image():
# Get parent job to get it's output image
current_job = rq.get_current_job(conn)
image_job_id = current_job.dependency.id
picture_bytes = queue_images.fetch_job(image_job_id).result
picture_bytes = queue_images.fetch_job(image_job_id).return_value()

img = cv2.imdecode(np.fromstring(picture_bytes, np.uint8), cv2.IMREAD_GRAYSCALE)
original_img = cv2.imdecode(np.fromstring(picture_bytes, np.uint8), cv2.IMREAD_COLOR)
img = cv2.cvtColor(original_img, cv2.COLOR_BGR2GRAY)
h, w = img.shape
x1, x2 = int(w * scale_x1), int(w * scale_x2)
y1, y2 = int(h * scale_y1), int(h * scale_y2)
Expand All @@ -49,7 +50,7 @@ def process_image():
raise Exception("There is wrong number of dots!")
return {
'number': len(blobs),
'original_image': picture_bytes,
'kp_image': cv2.imencode('.jpg', kp)[1].tobytes(), # Image with anal data
'original_image': cv2.imencode('.webp', original_img, [cv2.IMWRITE_WEBP_QUALITY, 95])[1].tobytes(),
'kp_image': cv2.imencode('.webp', kp, [cv2.IMWRITE_WEBP_QUALITY, 95])[1].tobytes(), # Image with anal data
'finished_time': datetime.datetime.now().timestamp(), # Idk if this is available somewhere in job data
}

0 comments on commit 5d95a2c

Please sign in to comment.