Video Processing
Configuration
dataclass
Source code in src/video_processing/configuration.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
from_args(args)
classmethod
Create Configuration object from parsed command-line arguments.
Source code in src/video_processing/configuration.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
VideoProcessor
Class to process the screen recording and transform it into a dataset of image files.
Source code in src/video_processing/processor.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
find_face_sequences()
Find sequences in video stream and extract unique faces.
Source code in src/video_processing/processor.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_offset_sequence_bounds(frames_before_marker, frames_after_marker)
Recalculate sequence bounds as offsets from the sequence markers.
Sequence markers mark the frames where the system recognized a face or the static icon was displayed. Some time before recognizing a face, the person must have appeared in the camera view. Some time after recognizing a face (not necessarily when the icon appears in the corner), the person must have left the camera view.
This approach calculates the start and end frames of each sequence based on offsets from the markers. Throw away the sequences that (supposedly) do not contain a face (face_index == 0).
Source code in src/video_processing/processor.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
get_sequence_lengths()
Convert sequence markers into a list of sequence lengths.
Sequence markers mark the beginning of new sequences. This function calculates the length of each sequence by finding the distance between consecutive markers.
Returns:
| Type | Description |
|---|---|
list[int]
|
list[int]: List of sequence lengths in frames |
Source code in src/video_processing/processor.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
print_sequence_analysis()
Print detailed analysis of sequence lengths and patterns.
Source code in src/video_processing/processor.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
sample_frames_from_sequence_offset_based(sequence_descriptors, samples_per_sequence)
Sampling strategy based on sequence descriptors - defined start and end frames.
Source code in src/video_processing/processor.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
sample_frames_from_sequences_naive(samples_per_sequence)
Sample given number of frames from each sequence.
Return a mapping of sampled frame indices (keys) to face indices (values) present on those frames.
Source code in src/video_processing/processor.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
save_sampled_camera_regions_from_sequences(frame_idx_to_face_idx)
Save camera regions from evenly distributed frames within each sequence.
For each sequence, this method samples frames evenly distributed across the sequence length and saves the camera region for each sampled frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples_per_sequence
|
Number of frames to sample from each sequence |
required |
Source code in src/video_processing/processor.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
naive_strategy(config)
Naive sampling strategy that samples frames from each sequence.
Source code in src/video_processing/processor.py
426 427 428 429 430 431 432 433 434 435 436 | |
offset_strategy(config)
Offset sampling strategy that samples frames based on sequence descriptors.
Source code in src/video_processing/processor.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
configuration
Configuration
dataclass
Source code in src/video_processing/configuration.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
from_args(args)
classmethod
Create Configuration object from parsed command-line arguments.
Source code in src/video_processing/configuration.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
filters
FaceDetectionFilter
Bases: FaceFilter
Source code in src/video_processing/filters.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
create_haar_cascade_classifier(cascade_path)
staticmethod
Create and return a Haar cascade classifier for face detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cascade_path
|
str
|
Path to the Haar cascade XML file |
required |
Returns:
| Type | Description |
|---|---|
CascadeClassifier
|
cv2.CascadeClassifier: Loaded Haar cascade classifier |
Source code in src/video_processing/filters.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
should_filter_out(gray_frame, previous_frame)
Filter out if no face is detected in the frame.
Source code in src/video_processing/filters.py
103 104 105 106 107 108 109 110 111 112 113 114 | |
type()
Return the type of filter.
Source code in src/video_processing/filters.py
133 134 135 | |
FaceFilter
Bases: ABC
Source code in src/video_processing/filters.py
14 15 16 17 18 19 20 21 22 23 24 25 | |
type()
abstractmethod
Return the type of filter.
Source code in src/video_processing/filters.py
22 23 24 25 | |
SimilarityFilter
Bases: FaceFilter
Source code in src/video_processing/filters.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
mse(frame1, frame2)
Calculate Mean Squared Error (MSE) between two frames.
Source code in src/video_processing/filters.py
44 45 46 47 | |
should_filter_out(gray_frame, previous_frame)
Filter out if the current frame is similar to the previous one based on MSE.
Source code in src/video_processing/filters.py
33 34 35 36 37 38 39 40 41 42 | |
type()
Return the type of filter.
Source code in src/video_processing/filters.py
49 50 51 | |
StatisticsFilter
Bases: FaceFilter
Source code in src/video_processing/filters.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
calculate_image_stats(gray_frame)
Calculate variance and mean of a grayscale image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gray_frame
|
ndarray
|
Grayscale image as numpy array |
required |
Returns: tuple: (variance, mean)
Source code in src/video_processing/filters.py
78 79 80 81 82 83 84 85 86 87 88 | |
should_filter_out(gray_frame, previous_frame)
Filter out if the frame's statistics match the configured values.
Source code in src/video_processing/filters.py
68 69 70 71 72 73 74 75 76 | |
type()
Return the type of filter.
Source code in src/video_processing/filters.py
90 91 92 | |
processor
VideoProcessor
Class to process the screen recording and transform it into a dataset of image files.
Source code in src/video_processing/processor.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
find_face_sequences()
Find sequences in video stream and extract unique faces.
Source code in src/video_processing/processor.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
get_offset_sequence_bounds(frames_before_marker, frames_after_marker)
Recalculate sequence bounds as offsets from the sequence markers.
Sequence markers mark the frames where the system recognized a face or the static icon was displayed. Some time before recognizing a face, the person must have appeared in the camera view. Some time after recognizing a face (not necessarily when the icon appears in the corner), the person must have left the camera view.
This approach calculates the start and end frames of each sequence based on offsets from the markers. Throw away the sequences that (supposedly) do not contain a face (face_index == 0).
Source code in src/video_processing/processor.py
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
get_sequence_lengths()
Convert sequence markers into a list of sequence lengths.
Sequence markers mark the beginning of new sequences. This function calculates the length of each sequence by finding the distance between consecutive markers.
Returns:
| Type | Description |
|---|---|
list[int]
|
list[int]: List of sequence lengths in frames |
Source code in src/video_processing/processor.py
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
print_sequence_analysis()
Print detailed analysis of sequence lengths and patterns.
Source code in src/video_processing/processor.py
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
sample_frames_from_sequence_offset_based(sequence_descriptors, samples_per_sequence)
Sampling strategy based on sequence descriptors - defined start and end frames.
Source code in src/video_processing/processor.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
sample_frames_from_sequences_naive(samples_per_sequence)
Sample given number of frames from each sequence.
Return a mapping of sampled frame indices (keys) to face indices (values) present on those frames.
Source code in src/video_processing/processor.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
save_sampled_camera_regions_from_sequences(frame_idx_to_face_idx)
Save camera regions from evenly distributed frames within each sequence.
For each sequence, this method samples frames evenly distributed across the sequence length and saves the camera region for each sampled frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples_per_sequence
|
Number of frames to sample from each sequence |
required |
Source code in src/video_processing/processor.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
naive_strategy(config)
Naive sampling strategy that samples frames from each sequence.
Source code in src/video_processing/processor.py
426 427 428 429 430 431 432 433 434 435 436 | |
offset_strategy(config)
Offset sampling strategy that samples frames based on sequence descriptors.
Source code in src/video_processing/processor.py
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
sequence_marker
SequenceMarker
dataclass
Information about beginning of a frame sequence in a video.
face_index is 0 if no face was detected in the frame.
Source code in src/video_processing/sequence_marker.py
4 5 6 7 8 9 10 11 12 | |