test_df.drop(['x', 'y', 'V'], 1, inplace=True)
Xs = test_df[['lagX_20', 'lagX_19', 'lagX_18', 'lagX_17', 'lagX_16',
'lagX_15', 'lagX_14', 'lagX_13', 'lagX_12', 'lagX_11', 'lagX_10',
'lagX_9', 'lagX_8', 'lagX_7', 'lagX_6', 'lagX_5', 'lagX_4', 'lagX_3',
'lagX_2', 'lagX_1']]
Xs = from_2d_array_to_nested(Xs.to_numpy())
Ys = test_df[['lagY_20', 'lagY_19', 'lagY_18', 'lagY_17',
'lagY_16', 'lagY_15', 'lagY_14', 'lagY_13', 'lagY_12', 'lagY_11',
'lagY_10', 'lagY_9', 'lagY_8', 'lagY_7', 'lagY_6', 'lagY_5', 'lagY_4',
'lagY_3', 'lagY_2', 'lagY_1']]
Ys = from_2d_array_to_nested(Ys.to_numpy())
Vs = test_df[['lagV_20', 'lagV_19', 'lagV_18',
'lagV_17', 'lagV_16', 'lagV_15', 'lagV_14', 'lagV_13', 'lagV_12',
'lagV_11', 'lagV_10', 'lagV_9', 'lagV_8', 'lagV_7', 'lagV_6', 'lagV_5',
'lagV_4', 'lagV_3', 'lagV_2', 'lagV_1']]
Vs = from_2d_array_to_nested(Vs.to_numpy())
X = pd.concat([Xs, Ys, Vs], 1)
# load the pre-trained classifier
clf = load(open('clf.pkl', 'rb'))
predcted = clf.predict(X)
idx = list(np.where(predcted == 1)[0])
print("**************************************")
print(idx)
idx = np.array(idx) - 10
print(idx)
if len(predicted_points) > 10:
predicted_points.pop(0)
if not bounce_detected and frame_num - last_bounce_frame > 10:
if round(V)==19 or round(V)==22 : # If Y acceleration is less than the negative threshold, say -15
bounce_detected = True
last_bounce_frame = frame_num
print("Bounce detected")
print("next_point", next_point)
print("frame_number", frame_num)
cv2.putText(frame, f'Frame: {frame_num}', (10, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
cv2.circle(frame, (cx, cy), 5, (0,0,255), 5)
cv2.circle(frame, (int(next_point[0]), int(next_point[1])), 5, (255, 0, 0), 10)
for i, p in enumerate(predicted_points):
color = (255,255,255)
cv2.circle(frame, p, 5, color, 2)
if bounce_detected:
cv2.putText(frame, 'Bounce Detected', (10, 350), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
if kf.x[3] > 0: # After a bounce is detected, wait until acceleration is above the threshold, say -5, to detect the bounce again
bounce_detected = False
# test_df_1=pd.DataFrame({'frame': frame_num , 'x': next_point[0], 'y':next_point[1], 'vx':vx,'vy':vy ,'V': V}, index=[0])
#test_df.concat(test_df_1)
#test_df=pd.concat([test_df,test_df_1], ignore_index=True)
#test_df.to_csv('file.csv')
cv2.imshow('raw', frame)
#test_df=pd.DataFrame()
# test_df=pd.concat([test_df,test_df_1], ignore_index=True)
# print(trajectory_df)
test_df.to_csv('file.csv')
#test_df_1=pd.DataFrame({'frame': frame_num , 'x': next_point[0], 'y':next_point[1], 'vx':vx,'vy':vy ,'V': V}, index=[0])
# Uncomment the following lines to save the output video
# out.write(frame)
# if cv2.waitKey(1) & 0xFF == ord('q'):
# break
error:
raise TypeError("X " + msg_invalid_input)
TypeError: X must be in an sktime compatible format, of scitype Series, Panel or Hierarchical, for instance a pandas.DataFrame with sktime compatible time indices, or with MultiIndex and last(-1) level an sktime compatible time index. Allowed compatible mtype format specifications are: ['pd.Series', 'pd.DataFrame', 'np.ndarray', 'nested_univ', 'numpy3D', 'pd-multiindex', 'df-list', 'pd_multiindex_hier'] . See the data format tutorial examples/AA_datatypes_and_datasets.ipynb. If you think the data is already in an sktime supported input format, run sktime.datatypes.check_raise(data, mtype) to diagnose the error, where mtype is the string of the type specification you want. Error message for checked mtypes, in format [mtype: message], as follows: [pd.DataFrame: X must have unique column indices, but found Int64Index([0, 0, 0], dtype='int64')] [pd.Series: X must be a pandas.Series, found <class 'pandas.core.frame.DataFrame'>] [np.ndarray: X must be a numpy.ndarray, found <class 'pandas.core.frame.DataFrame'>] [df-list: X must be list of pd.DataFrame, found <class 'pandas.core.frame.DataFrame'>] [numpy3D: X must be a numpy.ndarray, found <class 'pandas.core.frame.DataFrame'>] [pd-multiindex: X must have a MultiIndex, found <class 'pandas.core.indexes.range.RangeIndex'>] [nested_univ: X must have unique column indices, but found Int64Index([0, 0, 0], dtype='int64')] [pd_multiindex_hier: X must have a MultiIndex, found <class 'pandas.core.indexes.range.RangeIndex'>]