Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
VKR2025
imageparser
Commits
c3ba631d
Commit
c3ba631d
authored
1 week ago
by
Моисеев Николай Денисович
Browse files
Options
Download
Patches
Plain Diff
feat: add s3 saving
parent
fcd06b1b
master
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.env-example
+3
-0
.env-example
.gitignore
+174
-0
.gitignore
s3_saving.py
+80
-0
s3_saving.py
with
257 additions
and
0 deletions
+257
-0
.env-example
0 → 100644
+
3
−
0
View file @
c3ba631d
MINIO_ENDPOINT=
MINIO_ACCESS_KEY=
MINIO_SECRET_KEY=
\ No newline at end of file
This diff is collapsed.
Click to expand it.
.gitignore
0 → 100644
+
174
−
0
View file @
c3ba631d
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
\ No newline at end of file
This diff is collapsed.
Click to expand it.
s3_saving.py
0 → 100644
+
80
−
0
View file @
c3ba631d
import
os
from
io
import
BytesIO
from
PIL
import
Image
from
dotenv
import
load_dotenv
from
minio
import
Minio
import
streetview
from
routeparser
import
get_points_from_coordinates
class
Config
:
MINIO_ENDPOINT
:
str
MINIO_ACCESS_KEY
:
str
MINIO_SECRET_KEY
:
str
def
load_config
(
env_path
:
str
=
".env"
)
->
Config
:
if
os
.
path
.
exists
(
env_path
):
load_dotenv
(
env_path
)
cfg
=
Config
()
cfg
.
MINIO_ENDPOINT
=
os
.
getenv
(
"MINIO_ENDPOINT"
)
cfg
.
MINIO_ACCESS_KEY
=
os
.
getenv
(
"MINIO_ACCESS_KEY"
)
cfg
.
MINIO_SECRET_KEY
=
os
.
getenv
(
"MINIO_SECRET_KEY"
)
return
cfg
def
download_s3
(
start_lat
:
float
,
start_lon
:
float
,
end_lat
:
float
,
end_lon
:
float
,
minio_client
:
Minio
,
bucket_name
:
str
,
folder_name
:
str
):
points
=
get_points_from_coordinates
(
start_lat
,
start_lon
,
end_lat
,
end_lon
)
panoids_buffer
=
[]
print
(
len
(
points
))
for
point
in
points
:
panoids
=
streetview
.
panoids
(
lat
=
point
[
0
],
lon
=
point
[
1
],
closest
=
True
)
if
len
(
panoids
)
==
0
or
panoids
[
-
1
][
"panoid"
]
in
panoids_buffer
:
continue
panorama
=
streetview
.
download_panorama_v3
(
panoids
[
-
1
][
'panoid'
],
zoom
=
2
,
disp
=
False
)
panoids_buffer
.
append
(
panoids
[
-
1
][
'panoid'
])
image
=
Image
.
fromarray
(
panorama
)
buf
=
BytesIO
()
image
.
save
(
buf
,
format
=
'PNG'
)
buf
.
seek
(
0
)
minio_client
.
put_object
(
bucket_name
,
f
"
{
folder_name
}
/
{
panoids
[
-
1
][
'lat'
]
}
_
{
panoids
[
-
1
][
'lon'
]
}
.png"
,
buf
,
buf
.
getbuffer
().
nbytes
,
content_type
=
"image/png"
)
return
len
(
points
)
if
__name__
==
"__main__"
:
config
=
load_config
()
lat
,
lon
=
55.61727443131236
,
37.61265372859094
lat2
,
lon2
=
55.618037091058774
,
37.61304548448152
minio_client
=
Minio
(
endpoint
=
config
.
MINIO_ENDPOINT
,
access_key
=
config
.
MINIO_ACCESS_KEY
,
secret_key
=
config
.
MINIO_SECRET_KEY
)
download_s3
(
lat
,
lon
,
lat2
,
lon2
,
minio_client
,
"test"
,
"industrial_images"
)
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets