void eMPEGStreamInformation::fixupDiscontinuties() { m_timestamp_deltas.clear(); if (!m_access_points.size()) return; // eDebug("Fixing discontinuities ..."); /* if we have no delta at the beginning, extrapolate it */ if ((m_access_points.find(0) == m_access_points.end()) && (m_access_points.size() > 1)) { std::map<off_t,pts_t>::const_iterator second = m_access_points.begin(); std::map<off_t,pts_t>::const_iterator first = second++; if (first->first < second->first) /* i.e., not equal or broken */ { off_t diff = second->first - first->first; pts_t tdiff = second->second - first->second; tdiff *= first->first; tdiff /= diff; m_timestamp_deltas[0] = first->second - tdiff; // eDebug("first delta is %08llx", first->second - tdiff); } } if (m_timestamp_deltas.empty()) m_timestamp_deltas[m_access_points.begin()->first] = m_access_points.begin()->second; pts_t currentDelta = m_timestamp_deltas.begin()->second, lastpts_t = 0; for (std::map<off_t,pts_t>::const_iterator i(m_access_points.begin()); i != m_access_points.end(); ++i) { pts_t current = i->second - currentDelta; pts_t diff = current - lastpts_t; if (llabs(diff) > (90000*5)) // 5sec diff { // eDebug("%llx < %llx, have discont. new timestamp is %llx (diff is %llx)!", current, lastpts_t, i->second, diff); currentDelta = i->second - lastpts_t; /* FIXME: should be the extrapolated new timestamp, based on the current rate */ // eDebug("current delta now %llx, making current to %llx", currentDelta, i->second - currentDelta); m_timestamp_deltas[i->first] = currentDelta; } lastpts_t = i->second - currentDelta; } // eDebug("ok, found %d disconts.", m_timestamp_deltas.size()); #if 0 for (off_t x=0x25807E34ULL; x < 0x25B3CF70; x+= 100000) { off_t o = x; pts_t p; int r = getPTS(o, p); eDebug("%08llx -> %08llx | %08llx, %d, %08llx %08llx", x, getDelta(x), getInterpolated(x), r, o, p); } #endif }
glm::mat4 Skeleton::getMatrix(unsigned int frameIdx) const { const FrameTransform& ft = getInterpolated(frameIdx); glm::mat4 m; m = glm::translate( m, ft.translation ); m = m * glm::mat4_cast( ft.rotation ); return m; }
void ConnectionTracerRenderer ::drawTracer(const AbstractConnection& connection, std::shared_ptr<ofBaseRenderer>& renderer) { if (!connection.visible()) { return; } auto ratio = ofWrap(_rawRatio + static_cast<float>(connection.entityId() % 12) / 12.0f, 0, 1); auto tracerPos = connection.evaluatePosition(ratio); const auto& entityA = connection.sourceEntity(); const auto& entityB = connection.targetEntity(); auto color = getInterpolated(entityA.color(), entityB.color(), ratio); color.setBrightness(color.getBrightness() * 1.2); color.a *= getInterpolated(entityA.alpha(), entityB.alpha(), ratio); color.a *= _params.alphaFade.evaluate(ratio); renderer->setColor(color); renderer->drawBox(tracerPos, _params.drawRadius.get()); }
bool warpPatchHomography(const cv::Mat_<unsigned char> &im, const Eigen::Matrix<T,3,3> &H, cv::Mat_<unsigned char> &patch) { Eigen::Matrix<T,2,1> pt; for (int v=0; v<patch.rows; v++) { for (int u=0; u<patch.cols; u++) { mapPoint(Eigen::Matrix<T,2,1>(u,v), H, pt); if ((int)pt[0] < 0 || (int)pt[1] < 0 || int(pt[0])+1 >= im.cols || int(pt[1])+1 >= im.rows) return false; patch(v,u) = getInterpolated(im, pt); } } return true; }
bool warpPatchHomography(const unsigned char *im, int im_rows, int im_cols, const T H[9], unsigned char *patch, int p_rows, int p_cols) { T pt[2]; for (int v=0; v<p_rows; v++) { for (int u=0; u<p_cols; u++) { mapPoint(u,v, H, pt[0], pt[1]); if ((int)pt[0]<0 || (int)pt[1]<0 || int(pt[0])+1>=im_cols || int(pt[1])+1>=im_rows) { return false; } patch[v*p_cols+u] = getInterpolated(im, im_rows, im_cols, pt); } } return true; }
// this method is deprecated in 006 please use getInterpolated ofxPoint2f ofxPoint2f::interpolated( const ofxPoint2f& pnt, float p ) const{ return getInterpolated(pnt, p); }