Creating individual frames with labeled body parts and making a video.
(
videooutname,
clip,
Dataframe,
tmpfolder,
dotsize,
colormap,
alphavalue,
pcutoff,
trailpoints,
cropping,
x1,
x2,
y1,
y2,
save_frames,
bodyparts2plot,
outputframerate,
Frames2plot,
bodyparts2connect,
skeleton_color,
draw_skeleton,
displaycropped,
color_by,
plot_bboxes=True,
bboxes_list=None,
bboxes_pcutoff=0.6,
bboxes_color: str | None = None,
)
| 219 | |
| 220 | |
| 221 | def CreateVideoSlow( |
| 222 | videooutname, |
| 223 | clip, |
| 224 | Dataframe, |
| 225 | tmpfolder, |
| 226 | dotsize, |
| 227 | colormap, |
| 228 | alphavalue, |
| 229 | pcutoff, |
| 230 | trailpoints, |
| 231 | cropping, |
| 232 | x1, |
| 233 | x2, |
| 234 | y1, |
| 235 | y2, |
| 236 | save_frames, |
| 237 | bodyparts2plot, |
| 238 | outputframerate, |
| 239 | Frames2plot, |
| 240 | bodyparts2connect, |
| 241 | skeleton_color, |
| 242 | draw_skeleton, |
| 243 | displaycropped, |
| 244 | color_by, |
| 245 | plot_bboxes=True, |
| 246 | bboxes_list=None, |
| 247 | bboxes_pcutoff=0.6, |
| 248 | bboxes_color: str | None = None, |
| 249 | ): |
| 250 | """Creating individual frames with labeled body parts and making a video.""" |
| 251 | |
| 252 | if displaycropped: |
| 253 | ny, nx = y2 - y1, x2 - x1 |
| 254 | else: |
| 255 | ny, nx = clip.height(), clip.width() |
| 256 | |
| 257 | fps = clip.fps() |
| 258 | if outputframerate is None: # by def. same as input rate. |
| 259 | outputframerate = fps |
| 260 | |
| 261 | nframes = clip.nframes |
| 262 | duration = nframes / fps |
| 263 | |
| 264 | print(f"Duration of video [s]: {round(duration, 2)}, recorded with {round(fps, 2)} fps!") |
| 265 | print(f"Overall # of frames: {nframes} with cropped frame dimensions: {nx} {ny}") |
| 266 | print("Generating frames and creating video.") |
| 267 | df_x, df_y, df_likelihood = Dataframe.values.reshape((len(Dataframe), -1, 3)).T |
| 268 | if cropping and not displaycropped: |
| 269 | df_x += x1 |
| 270 | df_y += y1 |
| 271 | |
| 272 | bpts = Dataframe.columns.get_level_values("bodyparts") |
| 273 | all_bpts = bpts.values[::3] |
| 274 | if draw_skeleton: |
| 275 | bpts2connect = get_segment_indices(bodyparts2connect, all_bpts) |
| 276 | |
| 277 | bplist = bpts.unique().to_list() |
| 278 | nbodyparts = len(bplist) |
no test coverage detected