bool checkIfBlobsCrossedTheLine2(std::vector &blobs, int &intHorizontalLinePosition,int &intHorizontalLinePosition2, cv::Mat &imgFrame2Copy) {
bool blnAtLeastOneBlobCrossedTheLine = false;
for (auto blob : blobs) {
if (blob.blnStillBeingTracked == true && blob.centerPositions.size() >= 2) {
int prevFrameIndex = (int)blob.centerPositions.size() - 2;
int currFrameIndex = (int)blob.centerPositions.size() - 1;
if ((blob.centerPositions[prevFrameIndex].y > intHorizontalLinePosition && blob.centerPositions[currFrameIndex].y <= intHorizontalLinePosition)&&(blob.centerPositions[prevFrameIndex].y > intHorizontalLinePosition2 && blob.centerPositions[currFrameIndex].y <= intHorizontalLinePosition2)) {
int time = 30;
int distance = 200;
int speed = distance/time;
double dblFontScale = blobs[currFrameIndex].dblCurrentDiagonalSize / 10.0;
int intFontThickness = (int)std::round(dblFontScale * 1.0);
std::cout<<"Speed: "<<speed<<std::endl;
cv::putText(imgFrame2Copy, std::to_string(speed), blobs[currFrameIndex].centerPositions.back(), CV_FONT_HERSHEY_SIMPLEX, dblFontScale, SCALAR_RED, intFontThickness);
blnAtLeastOneBlobCrossedTheLine = true;
}
}
}
return blnAtLeastOneBlobCrossedTheLine;
}
Please i didn't understand why i can't display the speed of each vehicle, so help please
Aucun commentaire:
Enregistrer un commentaire