Skip to content

Commit 07e13d6

Browse files
committed
Improve style transfer model interface and performance.
1 parent 423a697 commit 07e13d6

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

demos/video/chapel-webcam/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ int mirror() {
117117
cv::Size processed_frame_size;
118118

119119
while (true) {
120+
121+
uint64_t start = cv::getTickCount();
122+
120123
// Capture a new frame from webcam
121124
cap >> frame;
122125
if (frame.empty()) {
@@ -142,10 +145,13 @@ int mirror() {
142145
cv::imshow(windowName, next_frame);
143146

144147
// Wait for 30ms or until 'q' key is pressed
145-
char key = static_cast<char>(cv::waitKey(30));
148+
char key = static_cast<char>(cv::waitKey(1));
146149
if (key == 'q' || key == 27) { // 'q' or ESC to quit
147150
break;
148151
}
152+
153+
double fps = cv::getTickFrequency() / (cv::getTickCount() - start);
154+
std::cout << "\rcv::FPS : " << fps << "\t\r" << std::flush;
149155
}
150156

151157
// Release the camera and destroy all windows

demos/video/chapel-webcam/smol.chpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ export proc getNewFrame(ref frame: [] real(32),height: int, width: int,channels:
109109
const dt = getTime() - lastFrame;
110110
const fps = 1.0 / dt;
111111

112+
/*
112113
runningSum += fps;
113114
frameCount += 1;
114115
const overallAvgFPS = runningSum / frameCount;
@@ -124,6 +125,8 @@ export proc getNewFrame(ref frame: [] real(32),height: int, width: int,channels:
124125
const currentWindowSize = min(frameCount, windowSize);
125126
const windowAvgFPS = windowSum / currentWindowSize;
126127
writeln("FPS: ", fps, " avg FPS: ", windowAvgFPS, "max window FPS: ", max reduce fpsBuffer);
128+
*/
129+
// writeln("FPS: ", fps);
127130
lastFrame = getTime();
128131

129132

0 commit comments

Comments
 (0)