Skip to content

Commit e47414a

Browse files
Fixed webcam bad start
1 parent 0d57f78 commit e47414a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

include/openpose/producer/webcamReader.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ namespace op
4040

4141
private:
4242
const int mIndex;
43+
const bool mWebcamStarted;
4344
long long mFrameNameCounter;
4445
bool mThreadOpened;
4546
cv::Mat mBuffer;

src/openpose/producer/webcamReader.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ namespace op
1010
const bool undistortImage) :
1111
VideoCaptureReader{webcamIndex, throwExceptionIfNoOpened, cameraParameterPath, undistortImage, 1},
1212
mIndex{webcamIndex},
13+
mWebcamStarted{VideoCaptureReader::isOpened()},
1314
mFrameNameCounter{-1},
1415
mThreadOpened{std::atomic<bool>{false}},
16+
mDisconnectedCounter{0},
1517
mResolution{webcamResolution}
1618
{
1719
try
@@ -83,7 +85,7 @@ namespace op
8385
{
8486
try
8587
{
86-
return (VideoCaptureReader::isOpened() || mDisconnectedCounter > 0);
88+
return (VideoCaptureReader::isOpened() || (mDisconnectedCounter > 0 && mWebcamStarted));
8789
}
8890
catch (const std::exception& e)
8991
{

0 commit comments

Comments
 (0)