在c ++中重复时钟时重置窗口的问题
我试图用时间来重置时间,chrono。但是,代码执行时间在没有初始化的情况下继续增加。
你好,我是韩国技术学院的学生。使用翻译器。请原谅我说话很尴尬。
我正在设计一个程序,它使用 C++ OpenPose 库来衡量正确的 PC 用户税。基本上,我们已经完成了右肩或左肩歪斜时浮动弹窗提供反馈的功能。但是,我想在一秒钟后发出警报,而不是在错误位置发送反馈。
应该在不执行假设功能时测量时间,但是当用户坐在错误的位置时。时间将从执行 supose 函数的时间开始计算。如果同一个座位在错误的座位上保持 20 秒,则应该发生事件。
该事件会在 20 秒后发生,如果时间没有初始化,一旦识别为不正确的姿势就会发生。我想是因为什么时候。如果库从哪里中断,则以 0 代码结束。
一旦我解决了与时间相关的函数,我会问你一个问题,因为我很难完成这个程序。谢谢你。
while (!userWantsToExit)
{
// start frame
std::shared_ptr<std::vector<UserDatum>> datumProcessed;
if (opWrapper.waitAndPop(datumProcessed))
{
userWantsToExit = userOutputClass.display(datumProcessed);
userOutputClass.printKeypoints(datumProcessed);
....
//string to int
int subShoulder = stoi(rShoulderY) - stoi(lShoulderY);
//clac keypoint values for posedata
if (50 < subShoulder || -50 > subShoulder)
{
if (stoi(rShoulderY) < stoi(lShoulderY)) {
clock_t t_start, t_end;
int time;
t_start = clock(); //start clock
time = t_start / CLOCKS_PER_SEC;
op::log(time);
if (time > 20) {
t_end = clock(); //end clock
time = (int)(t_end - t_start) / CLOCKS_PER_SEC;
cv::imshow("SUPOSE", imgLshoulderDown);
std::string id = "hjw";
std::string pose = "leftShoulder";
httpRequestPose(id, pose);
}
}
else if (stoi(rShoulderY) > stoi(lShoulderY)) {
clock_t t_start, t_end;
int time;
t_start = clock(); //start clock
time = t_start / CLOCKS_PER_SEC;
op::log(time);
if (time > 20) {
cv::imshow("SUPOSE", imgRshoulderDown);
std::string id = "hjw";
std::string pose = "rightShoulder";
httpRequestPose(id, pose);
}
t_end = clock();
time = (int)(t_end - t_start) / CLOCKS_PER_SEC;
}
else {
clock_t t_start, t_end;
int time;
t_end = clock();
time = (int)(t_end - t_start) / CLOCKS_PER_SEC;
}
}
}
else {}
//op::log("Processed datum could not be emplaced.", op::Priority::High, __LINE__, __FUNCTION__, __FILE__);
}
*图片