fix(api): Remove duplicate frames,change samples after disparity with enum BM
This commit is contained in:
parent
e85321130e
commit
f08dda33b5
|
@ -11,7 +11,9 @@
|
|||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
#include <string>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
|
||||
#include "mynteye/api/api.h"
|
||||
|
||||
|
@ -26,13 +28,15 @@ int main(int argc, char *argv[]) {
|
|||
if (!ok) return 1;
|
||||
api->ConfigStreamRequest(request);
|
||||
|
||||
api->SetDisparityComputingMethodType(DisparityComputingMethod::BM);
|
||||
api->EnableStreamData(Stream::DEPTH);
|
||||
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
cv::namedWindow("depth");
|
||||
|
||||
double t = 0;
|
||||
double fps;
|
||||
while (true) {
|
||||
api->WaitForStreams();
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ int main(int argc, char *argv[]) {
|
|||
auto &&request = api->SelectStreamRequest(&ok);
|
||||
if (!ok) return 1;
|
||||
api->ConfigStreamRequest(request);
|
||||
api->SetDisparityComputingMethodType(DisparityComputingMethod::BM);
|
||||
|
||||
api->EnableStreamData(Stream::POINTS);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ int main(int argc, char *argv[]) {
|
|||
auto &&request = api->SelectStreamRequest(&ok);
|
||||
if (!ok) return 1;
|
||||
api->ConfigStreamRequest(request);
|
||||
|
||||
api->SetDisparityComputingMethodType(DisparityComputingMethod::BM);
|
||||
api->Start(Source::VIDEO_STREAMING);
|
||||
|
||||
cv::namedWindow("frame");
|
||||
|
|
|
@ -25,6 +25,7 @@ int main(int argc, char *argv[]) {
|
|||
auto &&request = api->SelectStreamRequest(&ok);
|
||||
if (!ok) return 1;
|
||||
api->ConfigStreamRequest(request);
|
||||
api->SetDisparityComputingMethodType(DisparityComputingMethod::BM);
|
||||
|
||||
api->EnableStreamData(Stream::LEFT_RECTIFIED);
|
||||
api->EnableStreamData(Stream::RIGHT_RECTIFIED);
|
||||
|
|
|
@ -154,6 +154,7 @@ int main(int argc, char *argv[]) {
|
|||
auto &&request = api->SelectStreamRequest(&ok);
|
||||
if (!ok) return 1;
|
||||
api->ConfigStreamRequest(request);
|
||||
api->SetDisparityComputingMethodType(DisparityComputingMethod::BM);
|
||||
|
||||
api->SetOptionValue(Option::IR_CONTROL, 80);
|
||||
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
MYNTEYE_BEGIN_NAMESPACE
|
||||
|
||||
Processor::Processor(std::int32_t proc_period)
|
||||
: proc_period_(std::move(proc_period)),
|
||||
: last_frame_id_cd(0),
|
||||
last_frame_id_cd_vice(0),
|
||||
proc_period_(std::move(proc_period)),
|
||||
activated_(false),
|
||||
input_ready_(false),
|
||||
idle_(true),
|
||||
|
@ -278,11 +280,16 @@ api::StreamData Processor::GetStreamData(const Stream &stream) {
|
|||
if (enable_mode == Synthetic::MODE_ON) {
|
||||
if (sum == 1) {
|
||||
if (out != nullptr) {
|
||||
auto &&output = Object::Cast<ObjMat>(out);
|
||||
auto output = Object::Cast<ObjMat>(out);
|
||||
if (output != nullptr) {
|
||||
if (last_frame_id_cd == output->data->frame_id) {
|
||||
// cut the duplicate frame.
|
||||
return {};
|
||||
}
|
||||
last_frame_id_cd = output->data->frame_id;
|
||||
return obj_data(output);
|
||||
}
|
||||
VLOG(2) << "Rectify not ready now";
|
||||
VLOG(2) << "Frame not ready now";
|
||||
}
|
||||
} else if (sum == 2) {
|
||||
static std::shared_ptr<ObjMat2> output = nullptr;
|
||||
|
@ -295,15 +302,26 @@ api::StreamData Processor::GetStreamData(const Stream &stream) {
|
|||
for (auto it : streams) {
|
||||
if (it.stream == stream) {
|
||||
if (num == 1) {
|
||||
if (last_frame_id_cd == output->first_data->frame_id) {
|
||||
// cut the duplicate frame.
|
||||
return {};
|
||||
}
|
||||
last_frame_id_cd = output->first_data->frame_id;
|
||||
return obj_data_first(output);
|
||||
} else {
|
||||
// last_frame_id_cd = output->second_data->frame_id;
|
||||
if (last_frame_id_cd_vice == output->second_data->frame_id) {
|
||||
// cut the duplicate frame.
|
||||
return {};
|
||||
}
|
||||
last_frame_id_cd_vice = output->second_data->frame_id;
|
||||
return obj_data_second(output);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
VLOG(2) << "Rectify not ready now";
|
||||
VLOG(2) << "Frame not ready now";
|
||||
} else {
|
||||
LOG(ERROR) << "error: invalid sum!";
|
||||
}
|
||||
|
|
|
@ -90,7 +90,8 @@ class Processor :
|
|||
|
||||
virtual process_type ProcessOutputConnection();
|
||||
virtual process_type ProcessInputConnection();
|
||||
|
||||
std::uint16_t last_frame_id_cd;
|
||||
std::uint16_t last_frame_id_cd_vice;
|
||||
private:
|
||||
/** Run in standalone thread. */
|
||||
void Run();
|
||||
|
|
|
@ -90,10 +90,6 @@ void s1s2Processor::StartVideoStreaming() {
|
|||
[this, stream, callback](const device::StreamData &data) {
|
||||
auto &&stream_data = data2api(data);
|
||||
ProcessNativeStream(stream, stream_data);
|
||||
// Need mutex if set callback after start
|
||||
// if (callback) {
|
||||
// callback(stream_data);
|
||||
// }
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user