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

feat (web/server) 360 degrees Web panoramas #3098

Closed

Conversation

dmitry-brazhenko
Copy link
Contributor

@dmitry-brazhenko dmitry-brazhenko commented Jul 3, 2023

In this PR I aded

  1. Support for 360 Panoramas as it was discussed here: [Feature]: Panoramas: Use PhotoSphere Viewer to display photos with equirectangular projection #1630
  2. Minor technical changes and improvements

How it was implemented

  1. Once an images is uploaded, in metadata-extraction.processor.ts it checks aspectRatio. If it is aspectRatio >= 2, we assume that it is a panorama. This can be potentialy improved, but looks like a common way to determine if image is a panorama or not
  2. If it is a panorama, we add a prtoperty isPanorama: true
  3. We use library @egjs/svelte-view360 to show the panoram
  4. In the library we use a special symbol to display if a thumb is a panorama.

Minor technical changes and improvements:

  1. restart:always for all docker containers in development docker-compose
  2. Fixed links in database-migrations.md file

Potential further improvements:

  1. Probably we can switch library and use smth else. But this liibrary works OK both on desktop and mobile-web
  2. Support panoramas in Flutter mobile app
  3. There 360 videos. Later we can support them as well

Here is thumb that shows a panorama:
2023-07-03_17-48-25

Panorama after is opened:
2023-07-03_17-50-11

@vercel
Copy link

vercel bot commented Jul 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
immich ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2023 5:54pm

@dmitry-brazhenko
Copy link
Contributor Author

Probably I need to add some tests, but not sure. Need some advise.
Also I am not 100% sure that I properly fixed open-api-doc. Please help me with this stuff.
Thanks

@dmitry-brazhenko dmitry-brazhenko marked this pull request as ready for review July 3, 2023 15:51
@dmitry-brazhenko dmitry-brazhenko changed the title [Draft] 360 degrees Web panoramas 360 degrees Web panoramas Jul 3, 2023
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

You can try running make api to regenerate the api. You can also run the npm run check:all scripts in the web/server folders to make sure those all pass.

web/src/lib/components/assets/thumbnail/360arrow.svg Outdated Show resolved Hide resolved
@dmitry-brazhenko
Copy link
Contributor Author

dmitry-brazhenko commented Jul 3, 2023

For further steps for improvement we can add a "panorama" filter here:
2023-07-03_19-35-48

@dmitry-brazhenko
Copy link
Contributor Author

Hi!
Do you have any ideas what can be improved in this PR? Can we merge it? :)

@alextran1502
Copy link
Contributor

@dmitry-brazhenko hello, I haven't gotten a chance to review the PR yet. Once I do and if there is nothing else to address, it will be merged. Thank you for the contribution

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to include this css in the asset-viewer.svelte component directly via a <style> ... </style> tag at the end of the file instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to do that, but it did not work. Here is a lib example: https://github.com/naver/egjs-view360/blob/master/packages/svelte-view360/demo/App.svelte

I overrided original css file. I asked a question here, but the suggestion did not work.
I am not very good in frontend technologies. If there are any ways to enable, please let me know, I will fix it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it can work, but you might need to add something special to make the style not scoped to the component.

web/src/lib/components/asset-viewer/panorama-viewer.svelte Outdated Show resolved Hide resolved
Copy link
Contributor

@jrasm91 jrasm91 left a comment

Choose a reason for hiding this comment

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

Need to double check the API generated code, but other than that LGTM.

Comment on lines 176 to 177
localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isEnum}}
localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isEnum}}{{^isEnum}}
localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isEnum}}{{/isPrimitiveType}}{{/multipartFormData}}
localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isPrimitiveType}}{{^isPrimitiveType}}
localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isPrimitiveType}}{{/multipartFormData}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to double check where this change is coming from

@dmitry-brazhenko dmitry-brazhenko changed the title 360 degrees Web panoramas feat (web/server) 360 degrees Web panoramas Jul 6, 2023
@alextran1502
Copy link
Contributor

I think there is some issue with the recent rebase/merge, can you only include the changes to the panorama view?

@dmitry-brazhenko
Copy link
Contributor Author

After I ran "make api" - it resulted to multiple file changes

@alextran1502
Copy link
Contributor

These changes somehow reverting some of the changes that we made. How about you only include the changes in the server and mobile and leave the API generation for me?

@dmitry-brazhenko
Copy link
Contributor Author

Yes, I will do that

@dmitry-brazhenko dmitry-brazhenko force-pushed the web_panoramas branch 2 times, most recently from 2654895 to c6d23e8 Compare July 8, 2023 20:47
@dmitry-brazhenko
Copy link
Contributor Author

@alextran1502 I reverted my attempts to merge main branch to my branch.
Could you help me with merging please?
Thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from your PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from your PR

Copy link
Contributor Author

@dmitry-brazhenko dmitry-brazhenko Jul 9, 2023

Choose a reason for hiding this comment

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

Why not to keep it?
Once I started running Immich, it was failing as containers just stopped. Adding this restart;always helped me to get started.

btw, I removed it for now, but I can create a separate PR and merge it there

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this file from your PR

Copy link
Contributor Author

@dmitry-brazhenko dmitry-brazhenko Jul 9, 2023

Choose a reason for hiding this comment

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

Why remove it? I fixed the path?
https://github.com/immich-app/immich/tree/main/server/src/infra/entities

btw, I reverted it, but I can create a separate PR and merge it there

@dmitry-brazhenko
Copy link
Contributor Author

dmitry-brazhenko commented Jul 9, 2023

@alextran1502 would you mind if merge docker compose improvement and MD fix in a separate PR?

@uhthomas
Copy link
Member

uhthomas commented Jul 9, 2023

Fixes #2610 and #1630.

@brighteyed
Copy link
Contributor

If it is aspectRatio >= 2, we assume that it is a panorama

I think 360 panoramas should be detected more reliably in this PR. Currently, the code assumes that all images with an aspect ratio >= 2 are 360 panoramas.

But, for example:

  • Screenshots with landscape orientation should not be detected as 360 panoramas
  • Non-360 panoramas (for example, with cylindrical projection) should not be detected as 360 panoramas

I believe we should use the EXIF tag ProjectionType to detect 360 panoramas in addition to the aspect ratio check

@CodeWithMa
Copy link

If it is aspectRatio >= 2, we assume that it is a panorama

I think 360 panoramas should be detected more reliably in this PR. Currently, the code assumes that all images with an aspect ratio >= 2 are 360 panoramas.

But, for example:

* Screenshots with landscape orientation should not be detected as 360 panoramas

* Non-360 panoramas (for example, with cylindrical projection) should not be detected as 360 panoramas

I believe we should use the EXIF tag ProjectionType to detect 360 panoramas in addition to the aspect ratio check

I agree. My google pixel photosphere images have the following projection type:

Projection Type                 : equirectangular

I also have photoshere images that are not complete 360 degree images so the aspect ratio is not 2:1.

@dmitry-brazhenko
Copy link
Contributor Author

dmitry-brazhenko commented Jul 23, 2023

@CodeWithMa @brighteyed you're right. I fixed panorama detection. Now it consumes Exif and marks images by "panorama" only if there is a necessary exif tag.

@alextran1502 Could you help me with merging this PR?

Thanks

@alextran1502
Copy link
Contributor

Can you create another PR to consolidate the changes on the web and the server? Please put migrations into a single file. Once you've done that please ping me and I can help generating the API

Copy link
Contributor

@brighteyed brighteyed left a comment

Choose a reason for hiding this comment

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

If we transform isPanorama fields into projectionType it will be easier in the future to add additional types of projections (most likely cylindrical)

@@ -32,6 +32,7 @@ export class AssetResponseDto {
people?: PersonResponseDto[];
/**base64 encoded sha1 hash */
checksum!: string;
isPanorama!: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer projectionType field with the enum type

@@ -58,6 +59,7 @@ export function mapAsset(entity: AssetEntity): AssetResponseDto {
tags: entity.tags?.map(mapTag),
people: entity.faces?.map(mapFace),
checksum: entity.checksum.toString('base64'),
isPanorama: entity.isPanorama,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer projectionType field with the enum type

@@ -43,6 +43,9 @@ export class ExifEntity {
@Column({ type: 'float', nullable: true })
longitude!: number | null;

@Column({ type: 'varchar', nullable: true })
projectionType!: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use enum here?

server/package.json Show resolved Hide resolved
@dmitry-brazhenko
Copy link
Contributor Author

Will go on in this PR: #3412.

Implemented Projectiontype as enum

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.

6 participants