Skip to content

Commit e39ec60

Browse files
committed
copy of video + chached zones
1 parent b0f9bef commit e39ec60

File tree

8 files changed

+249
-51
lines changed

8 files changed

+249
-51
lines changed

.gitignore

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ flagged/
1515

1616

1717
# Include the Videos folder and its contents
18-
!Videos/
18+
Videos/**
1919
!Videos/cat3_mp4.mp4
20-
Videos/videoplayback.mp4
20+
2121
# Include the Labeled_data folder and its contents
22-
Labeled_data/cat3_mp4_reliability/**
23-
Labeled_data/videoplayback/**
2422

25-
Labeled_data/cat3_mp4/data/**
23+
Labeled_data/**
24+
!Labeled_data/cat3_mp4/**
2625

2726
# Ignore config and environment files
2827

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"frame": 3, "total_frames": 323}
1+
{"frame": 229, "total_frames": 323}

Labeled_data/cat3/export/cat3_metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Program Version": "7.2.0 (Linux)",
2+
"Program Version": "7.3.0 (Linux)",
33
"Video Name": "cat3",
44
"Labeling Mode": "Normal",
55
"Frame Rate": 25.0,

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ This application is designed for behavioral researchers to code self-contact (se
1818
#### Step 2: Run the Application
1919

2020
1. Open the extracted folder.
21-
2. Run the executable:
22-
- Windows: `TinyTouch.exe`
23-
- Linux: `TinyTouch`
24-
Tip (Linux): If you want to see progress logs (e.g., loading frames), run the app from a terminal using `./TinyTouch-<version>`.
21+
2. Run the executable:
22+
- Windows: `TinyTouch.exe`
23+
- Linux: `TinyTouch`
24+
25+
Tip (Linux): If you want to see logs, run the app from a terminal using `./TinyTouch-<version>`.
2526

2627
---
2728
### From Source (Python)
@@ -95,16 +96,16 @@ python3 src/main.py
9596
The tutorial was created for now a bit outdated version but might still help.
9697
[Watch the tutorial video (download it)](./assets/tutorial.mp4)
9798

98-
## Additional Notes
99-
100-
- **Settings Button:**
101-
102-
- Use the `Settings` button to change diagram size, dot size (touch markers), and video resolution.
103-
- Tip: Lower video resolution runs faster.
104-
105-
- **New Template:**
106-
107-
- by changing parameter `new_template` in the `config.json` to `true` you can label on the new template"
99+
## Additional Notes
100+
101+
- **Settings Button:**
102+
103+
- Use the `Settings` button to change diagram size, dot size (touch markers), and video resolution.
104+
- Tip: Lower video resolution runs faster.
105+
106+
- **New Template:**
107+
108+
- by changing parameter `new_template` in the `config.json` to `true` you can label on the new template"
108109

109110
- **Infant’s Gaze:**
110111

@@ -141,12 +142,12 @@ The tutorial was created for now a bit outdated version but might still help.
141142
- **Terminal Window:**
142143
- A terminal window will open with the application. Do not close it. If you encounter a bug, describe it and send a picture of the terminal window. It may contain error messages that will help with debugging.
143144

144-
## Bugs
145-
146-
- **Timeline Issues:**
147-
- Sometimes, the timeline may not turn yellow as expected. However, the touch still exists if you see green and red dots.
148-
- **Trajectory Plot Alignment:**
149-
- In Analysis, trajectory plots may appear misaligned. You can manually fix this using the pan tool on the top right of the graph.
145+
## Bugs
146+
147+
- **Timeline Issues:**
148+
- Sometimes, the timeline may not turn yellow as expected. However, the touch still exists if you see green and red dots.
149+
- **Trajectory Plot Alignment:**
150+
- In Analysis, trajectory plots may appear misaligned. You can manually fix this using the pan tool on the top right of the graph.
150151

151152
## Contact information
152153

config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"limb_parameter1": "Looking",
1010
"limb_parameter2": "LP2",
1111
"limb_parameter3": "LP34",
12-
"max_display_width": 1250,
13-
"max_display_height": 900,
12+
"max_display_width": 1080,
13+
"max_display_height": 920,
1414
"perf_enabled": false,
1515
"perf_log_every_s": 2.0,
1616
"perf_log_top_n": 6

src/frame_utils.py

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,70 @@
44
"""
55

66
import os
7+
import re
78
import sys
89
import time
910
import shutil
1011
import cv2
1112

1213

14+
_FRAME_RE = re.compile(r"^frame(\d+)\.(jpg|jpeg|png)$", re.IGNORECASE)
15+
FRAME_COUNT_TOLERANCE_PCT = 0.001 # allow up to 0.1% missing frames
16+
17+
1318
def check_items_count(folder_path, expected_count):
1419
items = os.listdir(folder_path) if os.path.exists(folder_path) else []
15-
print("INFO: Number of files in frames folder: ", len(items)-1)
16-
print("INFO: Number of expected frames in the folder", expected_count)
17-
return (len(items)-1) == expected_count
20+
total_items = len(items)
21+
frame_indices = []
22+
non_frame_items = []
23+
24+
for name in items:
25+
match = _FRAME_RE.match(name)
26+
if match:
27+
frame_indices.append(int(match.group(1)))
28+
else:
29+
non_frame_items.append(name)
30+
31+
frame_count = len(frame_indices)
32+
expected_files = (expected_count + 1) if expected_count is not None and expected_count >= 0 else expected_count
33+
34+
print("INFO: Frames dir exists:", os.path.exists(folder_path))
35+
print("INFO: Number of files in frames folder:", total_items)
36+
print("INFO: Frame files detected:", frame_count)
37+
if expected_files is not None:
38+
print("INFO: Expected frame files:", expected_files)
39+
print("INFO: Expected last frame index:", expected_count)
40+
allowed_missing = max(1, int(expected_files * FRAME_COUNT_TOLERANCE_PCT)) if expected_files > 0 else 0
41+
print(
42+
"INFO: Frame count tolerance:",
43+
f"{FRAME_COUNT_TOLERANCE_PCT * 100:.3f}% (allow {allowed_missing} missing frames)",
44+
)
45+
else:
46+
print("WARN: Expected frame count is undefined.")
47+
48+
if non_frame_items:
49+
sample = ", ".join(non_frame_items[:5])
50+
print(f"WARN: Non-frame items in folder: {len(non_frame_items)} (sample: {sample})")
51+
52+
if frame_indices:
53+
min_idx = min(frame_indices)
54+
max_idx = max(frame_indices)
55+
print(f"INFO: Frame index range in folder: {min_idx}..{max_idx}")
56+
if expected_count is not None and expected_count >= 0 and max_idx != expected_count:
57+
print("WARN: Max frame index does not match expected last index.")
58+
59+
if expected_files is None:
60+
return False
61+
allowed_missing = max(1, int(expected_files * FRAME_COUNT_TOLERANCE_PCT)) if expected_files > 0 else 0
62+
min_ok = expected_files - allowed_missing
63+
if frame_count < min_ok or frame_count > expected_files:
64+
print(f"WARN: Frame file count mismatch: expected {expected_files}, found {frame_count}")
65+
return False
66+
if frame_count != expected_files:
67+
print(
68+
f"WARN: Frame file count within tolerance: expected {expected_files}, found {frame_count}"
69+
)
70+
return True
1871

1972

2073
def create_frames(
@@ -61,7 +114,13 @@ def maybe_report(count, total, stage):
61114

62115
print("INFO: Creating frames from video...")
63116
vidcap = cv2.VideoCapture(video_path)
117+
is_opened = vidcap.isOpened()
64118
total_frames = int(vidcap.get(cv2.CAP_PROP_FRAME_COUNT))
119+
fps = vidcap.get(cv2.CAP_PROP_FPS)
120+
width = int(vidcap.get(cv2.CAP_PROP_FRAME_WIDTH))
121+
height = int(vidcap.get(cv2.CAP_PROP_FRAME_HEIGHT))
122+
print(f"INFO: VideoCapture opened: {is_opened}")
123+
print(f"INFO: Video properties: frames={total_frames}, fps={fps:.3f}, size={width}x{height}")
65124
success, image = vidcap.read()
66125
count = 0
67126
os.makedirs(frames_dir, exist_ok=True)
@@ -74,4 +133,7 @@ def maybe_report(count, total, stage):
74133
sys.stdout.write(f"\rGenerating frames... {progress:.2f}%")
75134
sys.stdout.flush()
76135
maybe_report(count, total_frames or count, "Generating frames")
136+
vidcap.release()
77137
print("\nINFO: Frames have been created successfully.")
138+
if total_frames and count != total_frames:
139+
print(f"WARN: Generated {count} frames, but OpenCV reported {total_frames} total frames.")

0 commit comments

Comments
 (0)