Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Snapshot Routine #1465

Merged
merged 1 commit into from
Oct 23, 2024
Merged

New Snapshot Routine #1465

merged 1 commit into from
Oct 23, 2024

Conversation

walesch-yan
Copy link
Collaborator

This PR adds changes to use the new snapshot routine, that we proposed in mxcube/mxcubecore#1048 and removes the old routine. It works by sending the canvas drawings as overlay-image to the server, which send back the overlay on top of the currently polled image from the camera.
I will keep this as a draft, since the new routine is not yet merged into the main branch of mxcubecore

mxcubeweb/routes/samplecentring.py Fixed Show resolved Hide resolved
Copy link
Collaborator

@axelboc axelboc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Just my two cents on a few things.

Comment on lines 30 to 34
const fimg = new fabric.Image(img);
fimg.scale(imageRatio);

canvas.setBackgroundImage(fimg);
canvas.renderAll();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be curious to know if we still need this preparation code (and corresponding cleanup code).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They did help create a cleaner overlay between the camera image and the canvas in the background

format: 'png',
backgroundColor: null,
})
.split(',')[1];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this split be done in the back-end? It would make the API contract simpler: a full data URI instead of just the image payload. This way the back-end could also check that it's receiving the expected PNG mime type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a great suggestion, I will make the necessary changes


canvas.setBackgroundImage(0);
canvas.renderAll();

const filename = `${proposal}-${currentSampleName}.jpeg`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We send PNG and receive JPEG in return. It's a bit counter-intuitive. Is there a particular reason?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@walesch-yan, thats perhaps me who did something strange when I rebased on esrf-develop. The code above: format: 'png' should perhaps have been format: 'jpeg'

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was my mistake as I wrote the back-end code after the sending part and before the receiving part and did not pay attention to it in between sorry about that

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries!

@marcus-oscarsson
Copy link
Member

@walesch-yan :), Ahh isort ... Sorry now there are some import conflicts. I also merged the corresponding PR on mxubcecore. So you can update pyproject.toml :)

@walesch-yan
Copy link
Collaborator Author

@walesch-yan :), Ahh isort ... Sorry now there are some import conflicts. I also merged the corresponding PR on mxubcecore. So you can update pyproject.toml :)

No problem, I will handle the rebase and thanks! :)

@walesch-yan
Copy link
Collaborator Author

I made the suggested changes, the isort rebase and set the correct version of mxcubecore in pyproject.toml

@walesch-yan walesch-yan marked this pull request as ready for review October 23, 2024 12:18
Co-authored-by: marcus-oscarsson <[email protected]>
@walesch-yan
Copy link
Collaborator Author

Aaand removed two more unused imports from sampleview.py

@marcus-oscarsson
Copy link
Member

Thanks !

@marcus-oscarsson marcus-oscarsson merged commit 994faa1 into develop Oct 23, 2024
19 checks passed
@marcus-oscarsson marcus-oscarsson deleted the snapshots branch October 23, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants