Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F110783447
move.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
Mon, Apr 28, 02:25
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Apr 30, 02:25 (2 d)
Engine
blob
Format
Raw Data
Handle
25762877
Attached To
R8797 solarPV
move.py
View Options
import
cv2
import
numpy
as
np
import
sys
import
shutil
import
os
class
Move
():
def
__init__
(
self
,
image_name
,
output_dir_name
):
self
.
image_name
=
image_name
self
.
output_dir_name
=
output_dir_name
self
.
image
=
cv2
.
imread
(
self
.
image_name
,
-
1
)
self
.
copied_image
=
self
.
image
.
copy
()
def
do_move
(
self
):
cv2
.
namedWindow
(
"MOVE"
,
cv2
.
WINDOW_NORMAL
)
## Magnifying the window for more precise labelling
cv2
.
resizeWindow
(
"MOVE"
,
1000
,
1000
)
## 1250
self
.
move_im
=
False
while
True
:
cv2
.
imshow
(
"MOVE"
,
self
.
image
)
#cv2.setMouseCallback("CROP",self.crop_for_mouse)
keypress
=
cv2
.
waitKey
(
1
)
if
keypress
==
ord
(
'y'
):
#move to the next file
self
.
move_im
=
True
break
if
keypress
==
ord
(
'n'
):
self
.
move_im
=
False
break
if
self
.
move_im
is
True
:
image_path
=
self
.
image_name
.
split
(
os
.
path
.
sep
)
image_dest_path
=
self
.
output_dir_name
+
'/PV/'
+
image_path
[
-
1
]
print
(
"Copying original image "
,
self
.
image_name
,
" to "
,
image_dest_path
)
shutil
.
copy
(
self
.
image_name
,
image_dest_path
)
label_path
=
os
.
sep
.
join
(
image_path
[:
-
1
])
+
'/labels/'
\
+
image_path
[
-
1
][:
-
4
]
+
'_label'
+
\
image_path
[
-
1
][
-
4
:]
label_dest_path
=
self
.
output_dir_name
+
'/PV/labels/'
\
+
image_path
[
-
1
][:
-
4
]
+
'_label'
+
\
image_path
[
-
1
][
-
4
:]
print
(
"Copying labelled image "
,
label_path
,
" to "
,
label_dest_path
)
shutil
.
copy
(
label_path
,
label_dest_path
)
else
:
image_path
=
self
.
image_name
.
split
(
os
.
path
.
sep
)
image_dest_path
=
self
.
output_dir_name
+
'/almostPV/'
+
image_path
[
-
1
]
print
(
"Copying original image "
,
self
.
image_name
,
" to "
,
image_dest_path
)
shutil
.
copy
(
self
.
image_name
,
image_dest_path
)
label_path
=
os
.
sep
.
join
(
image_path
[:
-
1
])
+
'/labels/'
\
+
image_path
[
-
1
][:
-
4
]
+
'_label'
+
\
image_path
[
-
1
][
-
4
:]
label_dest_path
=
self
.
output_dir_name
+
'/almostPV/labels/'
\
+
image_path
[
-
1
][:
-
4
]
+
'_label'
+
\
image_path
[
-
1
][
-
4
:]
print
(
"Copying labelled image "
,
label_path
,
" to "
,
label_dest_path
)
shutil
.
copy
(
label_path
,
label_dest_path
)
Event Timeline
Log In to Comment