Skip to content

Commit 7bc71b7

Browse files
committed
Merge branch 'master' of github.com:stereolabs/zed-open-capture
2 parents 31bf1f5 + a6c4983 commit 7bc71b7

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ The open-source library provides methods to access raw video frames, calibration
7575

7676
`$ sudo apt install opencv-dev`
7777

78+
### Clone the repository
79+
80+
$ git clone https://github.com/stereolabs/zed-open-capture.git
81+
$ cd zed-open-capture
82+
7883
### Add udev rule
7984
Stereo cameras such as ZED 2 and ZED Mini have built-in sensors (e.g. IMU) that are identified as USB HID devices.
8085
To be able to access the USB HID device, you must add a udev rule contained in the `udev` folder:
@@ -83,11 +88,6 @@ To be able to access the USB HID device, you must add a udev rule contained in t
8388
$ bash install_udev_rule.sh
8489
$ cd ..
8590

86-
### Clone the repository
87-
88-
$ git clone https://github.com/stereolabs/zed-open-capture.git
89-
$ cd zed-open-capture
90-
9191
### Build
9292

9393
#### Build library and examples

changelog.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# Changelog
22

3-
v0.2 - 2012 06 10
3+
v0.2.1 - 2020 02 08
44
-------------------
5+
* Fix FPS issue caused by wrong default timeout in `getLastFrame` function (see #10)
6+
7+
v0.2 - 2020 06 10
8+
-----------------
59
* Fix issue downloading camera settings for the rectification example
610
* Documentation refactoring
711
* New "sl_oc::video" namespace
@@ -11,7 +15,7 @@ v0.2 - 2012 06 10
1115
* Sensors data and image data are now returned as reference instead of pointer
1216
* Improved sensors data validity field
1317

14-
v0.1 - 2012 06 04
18+
v0.1 - 2020 06 04
1519
-----------------
1620
* Video grabber
1721
* Video grabber controls

examples/zed_oc_video_example.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@
2929
#include <opencv2/highgui/highgui.hpp>
3030
// <---- Includes
3131

32+
// #define TEST_FPS 1
33+
3234
// The main function
3335
int main(int argc, char *argv[])
3436
{
3537
// ----> Create Video Capture
36-
sl_oc::video::VideoCapture cap;
38+
sl_oc::video::VideoParams params;
39+
params.res = sl_oc::video::RESOLUTION::HD720;
40+
params.fps = sl_oc::video::FPS::FPS_60;
41+
42+
sl_oc::video::VideoCapture cap(params);
3743
if( !cap.initializeVideo() )
3844
{
3945
std::cerr << "Cannot open camera video capture" << std::endl;
@@ -44,6 +50,15 @@ int main(int argc, char *argv[])
4450
std::cout << "Connected to camera sn: " << cap.getSerialNumber() << std::endl;
4551
// <---- Create Video Capture
4652

53+
54+
55+
#ifdef TEST_FPS
56+
// Timestamp to check FPS
57+
double lastTime = static_cast<double>(getSteadyTimestamp())/1e9;
58+
// Frame timestamp to check FPS
59+
uint64_t lastFrameTs = 0;
60+
#endif
61+
4762
// Infinite video grabbing loop
4863
while (1)
4964
{
@@ -53,6 +68,24 @@ int main(int argc, char *argv[])
5368
// ----> If the frame is valid we can display it
5469
if(frame.data!=nullptr)
5570
{
71+
#ifdef TEST_FPS
72+
if(lastFrameTs!=0)
73+
{
74+
// ----> System time
75+
double now = static_cast<double>(getSteadyTimestamp())/1e9;
76+
double elapsed_sec = now - lastTime;
77+
lastTime = now;
78+
std::cout << "[System] Frame period: " << elapsed_sec << "sec - Freq: " << 1./elapsed_sec << " Hz" << std::endl;
79+
// <---- System time
80+
81+
// ----> Frame time
82+
double frame_dT = static_cast<double>(frame.timestamp-lastFrameTs)/1e9;
83+
std::cout << "[Camera] Frame period: " << frame_dT << "sec - Freq: " << 1./frame_dT << " Hz" << std::endl;
84+
// <---- Frame time
85+
}
86+
lastFrameTs = frame.timestamp;
87+
#endif
88+
5689
// ----> Conversion from YUV 4:2:2 to BGR for visualization
5790
cv::Mat frameYUV = cv::Mat( frame.height, frame.width, CV_8UC2, frame.data );
5891
cv::Mat frameBGR;

include/videocapture.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class SL_OC_EXPORT VideoCapture
9191
* \note Frame received will contains the RAW buffer from the camera, in YUV4:2:2 color format and in side by side mode.
9292
* Images must then be converted to RGB for proper display and will not be rectified.
9393
*/
94-
const Frame& getLastFrame(uint64_t timeout_msec=10);
94+
const Frame& getLastFrame(uint64_t timeout_msec=100);
9595

9696
/*!
9797
* \brief Get the size of the camera frame

src/videocapture.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,11 @@ void VideoCapture::grabThreadFunc()
819819
memcpy(mLastFrame.data, (unsigned char*) mBuffers[mCurrentIndex].start, mBuffers[mCurrentIndex].length);
820820
mLastFrame.timestamp = mStartTs + rel_ts;
821821

822-
//std::cout << "Video:\t" << mLastFrame.timestamp << std::endl;
822+
// static uint64_t last_ts=0;
823+
// std::cout << "[Video] Frame TS: " << static_cast<double>(mLastFrame.timestamp)/1e9 << " sec" << std::endl;
824+
// double dT = static_cast<double>(mLastFrame.timestamp-last_ts)/1e9;
825+
// last_ts = mLastFrame.timestamp;
826+
// std::cout << "[Video] Frame FPS: " << 1./dT << std::endl;
823827

824828
#ifdef SENSORS_MOD_AVAILABLE
825829
if(mSensReadyToSync)

0 commit comments

Comments
 (0)