[~] Refactor

This commit is contained in:
Siarhei Siniak 2021-07-22 11:16:38 +03:00
parent 86c4b4f931
commit edd3100759

@ -1022,43 +1022,56 @@ def kernel_15(
t2 = 'baseball glove' t2 = 'baseball glove'
t3 = o_14['o_13']['t1'] t3 = o_14['o_13']['t1']
t4 = numpy.where(t3.name.data == t2)[0] t4 = numpy.where(t3.name.data == t2)[0]
t5 = t4[-1]
t6 = t3.video_path.data[t5]
t7 = t3.frame_id.data[t5]
t8 = t3.to_dataframe().iloc[t5]
pprint.pprint([t6, t7])
pprint.pprint(t8)
import cv2 for k in tqdm.tqdm(range(-10, -1)):
import matplotlib.pyplot t5 = t4[-1]
t6 = t3.video_path.data[t5]
t7 = t3.frame_id.data[t5]
t8 = t3.to_dataframe().iloc[t5]
pprint.pprint([t6, t7])
pprint.pprint(t8)
t9 = cv2.VideoCapture(t6) import cv2
t9.set(cv2.CAP_PROP_POS_FRAMES, t7) import matplotlib.pyplot
t10 = t9.read()
t9.release() t9 = cv2.VideoCapture(t6)
t11 = t10[1] t9.set(cv2.CAP_PROP_POS_FRAMES, t7)
t12 = cv2.cvtColor(t11, cv2.COLOR_BGR2RGB) t10 = t9.read()
t13 = t12.copy() t9.release()
t15 = numpy.array([t8.xcenter, t8.ycenter, t8.width, t8.height]) t11 = t10[1]
t16 = numpy.array([t13.shape[1], t13.shape[0], t13.shape[1], t13.shape[0]]) t12 = cv2.cvtColor(t11, cv2.COLOR_BGR2RGB)
t17 = t15 * t16 t13 = t12.copy()
t18 = t17[:2] - t17[2:] / 2 t15 = numpy.array([t8.xcenter, t8.ycenter, t8.width, t8.height])
t19 = t17[:2] + t17[2:] / 2 t16 = numpy.array([t13.shape[1], t13.shape[0], t13.shape[1], t13.shape[0]])
t20 = numpy.array([ t17 = t15 * t16
t18[0], t18[1], t18 = t17[:2] - t17[2:] / 2
t19[0], t19[1], t19 = t17[:2] + t17[2:] / 2
]) t20 = numpy.array([
t21 = numpy.round(t20).astype(numpy.int32) t18[0], t18[1],
t14 = cv2.rectangle( t19[0], t19[1],
t13, ])
tuple(t21[:2]), t21 = numpy.round(t20).astype(numpy.int32)
tuple(t21[2:]), t14 = cv2.rectangle(
(0, 255, 0), t13,
1, tuple(t21[:2]),
) tuple(t21[2:]),
pprint.pprint( (0, 255, 0),
locals() 1,
) )
pprint.pprint(
locals()
)
f = matplotlib.pyplot.figure()
matplotlib.pyplot.title(
'name %s, score %s, frame_id %d' % (
t8.name,
t8.confidence,
t8.frame_id,
)
)
matplotlib.pyplot.imshow(t14)
f.savefig('kernel_15-%05d.png' % t7)
matplotlib.pyplot.close(f)
return dict( return dict(