42 CapturingImageProvider::startCapture(
float framesPerSecond,
const Ice::Current& ctx)
44 std::unique_lock lock(captureMutex);
45 onStartCapture(framesPerSecond);
47 captureEnabled =
true;
48 frameRate = framesPerSecond;
50 ARMARX_INFO <<
"Starting image capture with " << frameRate <<
"fps";
54 CapturingImageProvider::stopCapture(
const Ice::Current& ctx)
56 std::unique_lock lock(captureMutex);
57 captureEnabled =
false;
65 CapturingImageProvider::onInitImageProvider()
68 frameRate = hasProperty(
"FPS") ? getProperty<float>(
"FPS").getValue() : 30;
69 captureEnabled =
false;
72 setImageSyncMode(eFpsSynchronization);
75 onInitCapturingImageProvider();
84 CapturingImageProvider::onConnectImageProvider()
86 onStartCapturingImageProvider();
91 startCapture(frameRate);
95 CapturingImageProvider::onExitImageProvider()
105 onExitCapturingImageProvider();
109 CapturingImageProvider::capture()
111 ARMARX_INFO <<
"Starting Image Provider: " << getName();
114 std::chrono::milliseconds td(1);
116 while (!captureTask->isStopped() && !isExiting() && sharedMemoryProvider)
118 auto tmpSharedMemoryProvider = sharedMemoryProvider;
119 if (captureEnabled && tmpSharedMemoryProvider)
122 MetaInfoSizeBasePtr info = tmpSharedMemoryProvider->getMetaInfo();
124 long oldTimestamp = info ? info->timeProvided : 0;
125 bool succeeded = capture(imageBuffers);
129 MetaInfoSizeBasePtr info = tmpSharedMemoryProvider->getMetaInfo();
132 if (!info || info->timeProvided == oldTimestamp)
135 <<
"The image provider did not set a timestamp - measuring "
136 "the timestamp now. The ImageProvider implementation "
137 "should call updateTimestamp()!";
138 updateTimestamp(image_timestamp.toMicroSeconds());
142 image_timestamp = IceUtil::Time::microSeconds(info->timeProvided);
144 auto imageProcessorProxy = this->imageProcessorProxy;
145 recordImages(image_timestamp);
147 imageProcessorProxy->reportImageAvailable(getName());
150 if (imageSyncMode == eFpsSynchronization)
152 fpsCounter.assureFPS(frameRate);
153 setMetaInfo(
"fps",
new Variant(fpsCounter.getFPS()));
154 setMetaInfo(
"minCycleTimeMs",
new Variant(fpsCounter.getMinCycleTimeMS()));
155 setMetaInfo(
"maxCycleTimeMs",
new Variant(fpsCounter.getMaxCycleTimeMS()));
156 auto dimension = getImageFormat().dimension;
157 setMetaInfo(
"resolution",
164 std::this_thread::sleep_for(td);
175 CapturingImageProvider::setImageSyncMode(ImageSyncMode imageSyncMode)
177 this->imageSyncMode = imageSyncMode;
181 CapturingImageProvider::getImageSyncMode()
183 return imageSyncMode;