Skip to content

Commit

Permalink
Added test to check exif rotated images width/height (#6384)
Browse files Browse the repository at this point in the history
<!-- Raise an issue to propose your change
(https://github.com/opencv/cvat/issues).
It helps to avoid duplication of efforts from multiple independent
contributors.
Discuss your ideas with maintainers to be sure that changes will be
approved and merged.
Read the [Contribution
guide](https://opencv.github.io/cvat/docs/contributing/). -->

<!-- Provide a general summary of your changes in the Title above -->

### Motivation and context
<!-- Why is this change required? What problem does it solve? If it
fixes an open
issue, please link to the issue here. Describe your changes in detail,
add
screenshots. -->

### How has this been tested?
<!-- Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to
see how your change affects other areas of the code, etc. -->

### Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply.
If an item isn't applicable for some reason, then ~~explicitly
strikethrough~~ the whole
line. If you don't do that, GitHub will show incorrect progress for the
pull request.
If you're unsure about any of these, don't hesitate to ask. We're here
to help! -->
- [x] I submit my changes into the `develop` branch
- [ ] I have added a description of my changes into the
[CHANGELOG](https://github.com/opencv/cvat/blob/develop/CHANGELOG.md)
file
- [ ] I have updated the documentation accordingly
- [x] I have added tests to cover my changes
- [ ] I have linked related issues (see [GitHub docs](

https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword))
- [ ] I have increased versions of npm packages if it is necessary

([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning),

[cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning),

[cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning)
and

[cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning))

### License

- [x] I submit _my code changes_ under the same [MIT License](
https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the
project.
  Feel free to contact the maintainers if that's a concern.
  • Loading branch information
bsekachev authored Jun 28, 2023
1 parent 7f6080e commit f6420eb
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 6 deletions.
3 changes: 0 additions & 3 deletions cvat-ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ module.exports = (env) => {
publicPath: '/',
},
devServer: {
devMiddleware: {
writeToDisk: true,
},
compress: false,
host: process.env.CVAT_UI_HOST || 'localhost',
client: {
Expand Down
2 changes: 1 addition & 1 deletion cvat/apps/engine/media_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def save_as_chunk(self, images, chunk_path):
output = io.BytesIO()
if self._dimension == DimensionType.DIM_2D:
pil_image = rotate_within_exif(Image.open(image))
pil_image.save(output, format=pil_image.format if pil_image.format else ext or self.IMAGE_EXT, quality=100, subsampling=0)
pil_image.save(output, format=pil_image.format if pil_image.format else self.IMAGE_EXT, quality=100, subsampling=0)
else:
output, ext = self._write_pcd_file(image)[0:2]
arcname = '{:06d}.{}'.format(idx, ext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ context('Connected file share.', () => {
cy.get('button').contains('images').click();
cy.wait('@shareRequest').then((interception) => {
expect(interception.response.body
.sort((a, b) => a.name.localeCompare(b.name)))
.sort((a, b) => a.name.localeCompare(b.name))
.filter((el) => el.mime_type === 'image'))
.to.deep.equal(expectedImagesList);
});
expectedImagesList.forEach((el) => {
Expand Down
3 changes: 2 additions & 1 deletion tests/cypress/e2e/actions_tasks3/case_118_multi_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ context('Create mutli tasks.', () => {
cy.get('button').contains('images').click();
cy.wait('@shareRequest').then((interception) => {
expect(interception.response.body
.sort((a, b) => a.name.localeCompare(b.name)))
.sort((a, b) => a.name.localeCompare(b.name))
.filter((el) => el.mime_type === 'image'))
.to.deep.equal(expectedImagesList);
});
expectedImagesList.forEach((el) => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions tests/python/rest_api/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import os
import os.path as osp
import zipfile
from copy import deepcopy
from functools import partial
from http import HTTPStatus
Expand Down Expand Up @@ -689,6 +690,39 @@ def test_can_create_task_with_defined_start_and_stop_frames(self):
(task, _) = api_client.tasks_api.retrieve(task_id)
assert task.size == 4

def test_can_create_task_with_exif_rotated_images(self):
task_spec = {
"name": f"test {self._USERNAME} to create a task with exif rotated images",
"labels": [
{
"name": "car",
}
],
}

image_files = ["images/exif_rotated/left.jpg", "images/exif_rotated/right.jpg"]
task_data = {
"server_files": image_files,
"image_quality": 70,
"segment_size": 500,
"use_cache": True,
"sorting_method": "natural",
}

task_id, _ = create_task(self._USERNAME, task_spec, task_data)

# check that the frames have correct width and height
with make_api_client(self._USERNAME) as api_client:
_, response = api_client.tasks_api.retrieve_data(
task_id, number=0, type="chunk", quality="original"
)
with zipfile.ZipFile(io.BytesIO(response.data)) as zip_file:
for name in zip_file.namelist():
with zip_file.open(name) as zipped_img:
im = Image.open(zipped_img)
# original is 480x640 with 90/-90 degrees rotation
assert im.height == 640 and im.width == 480

def test_can_create_task_with_sorting_method_natural(self):
task_spec = {
"name": f"test {self._USERNAME} to create a task with a custom sorting method",
Expand Down

0 comments on commit f6420eb

Please sign in to comment.