MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / medianBetweenValidPoints

Function medianBetweenValidPoints

rtpose_wrapper/apps/rtpose.cpp:361–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361double medianBetweenValidPoints(const cv::Mat& Input){
362 std::vector<ushort> array;
363 if (Input.isContinuous()) {
364 array.assign(Input.datastart, Input.dataend);
365 } else {
366 for (int i = 0; i < Input.rows; ++i) {
367 array.insert(array.end(), Input.ptr<ushort>(i),
368 Input.ptr<ushort>(i)+Input.cols);
369 }
370 }
371 // jump over the 0s
372 std::vector<ushort> array_with_no_zero;
373 array_with_no_zero.reserve(array.size());
374 for(uint i = 0; i < array.size(); ++i)
375 {
376 if (not fabs(array[i]) < 0.01f)
377 {
378 array_with_no_zero.push_back(array[i]);
379 }
380 }
381 if (array_with_no_zero.size() == 0) return 0.0f;
382 auto nth_position = array_with_no_zero.begin() +
383 array_with_no_zero.size() / 2;
384 std::nth_element(array_with_no_zero.begin(),
385 nth_position,
386 array_with_no_zero.end());
387 return array_with_no_zero[array_with_no_zero.size() * 0.5];
388}
389double medianBetweenValidPoints(std::vector<double>& array){
390 std::vector<double> array2;
391 array2.reserve(array.size());

Callers 2

getJoint3DFunction · 0.85
displayFrameFunction · 0.85

Calls 4

assignMethod · 0.80
endMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected