Skip to content

Commit 19839a7

Browse files
committed
update README.md - timing analyzing
1 parent e87ef07 commit 19839a7

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,24 @@ chmod 700 utils/clean.bash
2424
./utils/clean.bash < .gitignore
2525
```
2626

27-
## Webcam Stream and measure FPS
28-
Use **chrono** library to measure time and number of frame per second.
27+
## Webcam Stream
28+
The detach method ```t1.detach()``` is used because the main thread don't need to wait for thream being processing and return. Instead, it will get the dataframe. The process happens simultaneously.
2929

30+
## Measuring FPS and Elapsed time
31+
I first use **chrono** liberary to measure the time but found that it's hard to convert to seconds unit for calculating FPS. So, I use **ctime**.
32+
```c
33+
# in utils.cpp
34+
#include <ctime>
35+
36+
numFrames = 100;
37+
38+
clock_t start = clock();
39+
# some function here
40+
clock_t end = clock();
41+
42+
double elapsed_secs = double(end - start) / CLOCKS_PER_SEC;
43+
double fps = numFrames / elapsed_secs;
44+
```
3045

3146
## Face Dection using dlib
3247
http://dlib.net/webcam_face_pose_ex.cpp.html
@@ -41,20 +56,22 @@ for i in {1..10}; do
4156
./bin/thread_opencv_cpp 1000 >> output.txt
4257
done
4358
```
59+
4460
Test 10 times with multithreading
4561
| frames | Elapsed (Avg) | FPS (Avg) |
4662
| ------------- | ------------- | ------------- |
47-
| 100 | 1.57126 | 63.6563 |
63+
| 100 | 1.57126 | 63.6563 |
4864
| 1000 | 14.5097 | 68.9689 |
4965

5066

51-
Test 20 times w/o multithreading
67+
Test 10 times w/o multithreading
5268
| frames | Elapsed (Avg) | FPS (Avg) |
5369
| ------------- | ------------- | ------------- |
5470
| 100 | 1.95773 | 51.0956 |
5571
| 1000 | 13.9149 | 52.4172 |
5672

5773

74+
The elapsed time don't see any change; however, the FPS of streaming 100 and 1000 frames increase by 23.5% and 31.5%, respectively.
5875

5976

6077
## References

0 commit comments

Comments
 (0)