Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F111178048
scan_images.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Apr 30, 01:19
Size
1 KB
Mime Type
text/x-python
Expires
Fri, May 2, 01:19 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25863870
Attached To
R8797 solarPV
scan_images.py
View Options
from
crop
import
*
from
move
import
*
from
imutils
import
paths
import
argparse
import
os
parser
=
argparse
.
ArgumentParser
(
description
=
'Labeling tools'
)
parser
.
add_argument
(
'--dir'
,
help
=
'Directory containing the input images'
)
parser
.
add_argument
(
'--outdir'
,
help
=
'Directory containing the scanned images'
)
parser
.
add_argument
(
'--batch_size'
,
type
=
int
,
help
=
'Number of images to be processed
\
starting from 0'
)
args
=
vars
(
parser
.
parse_args
())
imagePaths
=
sorted
([
os
.
path
.
join
(
args
[
'dir'
],
f
)
for
f
in
os
.
listdir
(
args
[
'dir'
])
\
if
os
.
path
.
isfile
(
os
.
path
.
join
(
args
[
'dir'
],
f
))])
#imagePaths = sorted(list(paths.list_images(args["dir"])))
imagedir
=
imagePaths
[
0
]
.
split
(
os
.
path
.
sep
)
imagedir
=
os
.
sep
.
join
(
imagedir
[:
-
1
])
outputdir
=
args
[
'outdir'
]
PV_dir
=
imagedir
+
'/PV'
PV_label_dir
=
imagedir
+
'/PV'
+
'/labels'
PVout_dir
=
outputdir
+
'/PV'
PVout_label_dir
=
outputdir
+
'/PV'
+
'/labels'
almostPVout_dir
=
outputdir
+
'/almostPV'
almostPVout_label_dir
=
outputdir
+
'/almostPV'
+
'/labels'
#Create the directories if they do not exist
if
not
os
.
path
.
exists
(
PV_dir
):
os
.
makedirs
(
PV_dir
)
if
not
os
.
path
.
exists
(
PV_label_dir
):
os
.
makedirs
(
PV_label_dir
)
if
not
os
.
path
.
exists
(
PVout_dir
):
os
.
makedirs
(
PVout_dir
)
if
not
os
.
path
.
exists
(
PVout_label_dir
):
os
.
makedirs
(
PVout_label_dir
)
if
not
os
.
path
.
exists
(
almostPVout_dir
):
os
.
makedirs
(
almostPVout_dir
)
if
not
os
.
path
.
exists
(
almostPVout_label_dir
):
os
.
makedirs
(
almostPVout_label_dir
)
for
image
in
imagePaths
[
0
:
args
[
"batch_size"
]]:
# _ = input('Do you want to quit?')
# if _ == 'y':
# break
# else:
if
(
not
image
.
endswith
(
'.DS_Store'
)):
print
(
image
)
#print(PVout_dir)
#print(PVout_label_dir)
#print(almostPVout_dir)
#print(almostPVout_label_dir)
m
=
Move
(
image
,
outputdir
)
m
.
do_move
()
Event Timeline
Log In to Comment