本文整理汇总了C++中KeyframeVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyframeVector::size方法的具体用法?C++ KeyframeVector::size怎么用?C++ KeyframeVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyframeVector
的用法示例。
在下文中一共展示了KeyframeVector::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addKeyframesToCurve
void CompositorAnimationsImpl::addKeyframesToCurve(blink::WebAnimationCurve& curve, const KeyframeVector& keyframes, const TimingFunction& timingFunction)
{
for (size_t i = 0; i < keyframes.size(); i++) {
const TimingFunction* keyframeTimingFunction = 0;
if (i + 1 < keyframes.size()) { // Last keyframe has no timing function
switch (timingFunction.type()) {
case TimingFunction::LinearFunction:
case TimingFunction::CubicBezierFunction:
keyframeTimingFunction = &timingFunction;
break;
case TimingFunction::ChainedFunction: {
const ChainedTimingFunction& chained = toChainedTimingFunction(timingFunction);
// ChainedTimingFunction criteria was checked in isCandidate,
// assert it is valid.
ASSERT(keyframes.size() == chained.m_segments.size() + 1);
keyframeTimingFunction = chained.m_segments[i].m_timingFunction.get();
break;
}
case TimingFunction::StepsFunction:
default:
ASSERT_NOT_REACHED();
}
}
ASSERT(!keyframes[i]->value()->dependsOnUnderlyingValue());
RefPtr<AnimatableValue> value = keyframes[i]->value()->compositeOnto(0);
switch (curve.type()) {
case blink::WebAnimationCurve::AnimationCurveTypeFilter: {
OwnPtr<blink::WebFilterOperations> ops = adoptPtr(blink::Platform::current()->compositorSupport()->createFilterOperations());
bool converted = toWebFilterOperations(toAnimatableFilterOperations(value.get())->operations(), ops.get());
ASSERT_UNUSED(converted, converted);
blink::WebFilterKeyframe filterKeyframe(keyframes[i]->offset(), ops.release());
blink::WebFilterAnimationCurve* filterCurve = static_cast<blink::WebFilterAnimationCurve*>(&curve);
addKeyframeWithTimingFunction(*filterCurve, filterKeyframe, keyframeTimingFunction);
break;
}
case blink::WebAnimationCurve::AnimationCurveTypeFloat: {
blink::WebFloatKeyframe floatKeyframe(keyframes[i]->offset(), toAnimatableDouble(value.get())->toDouble());
blink::WebFloatAnimationCurve* floatCurve = static_cast<blink::WebFloatAnimationCurve*>(&curve);
addKeyframeWithTimingFunction(*floatCurve, floatKeyframe, keyframeTimingFunction);
break;
}
case blink::WebAnimationCurve::AnimationCurveTypeTransform: {
OwnPtr<blink::WebTransformOperations> ops = adoptPtr(blink::Platform::current()->compositorSupport()->createTransformOperations());
toWebTransformOperations(toAnimatableTransform(value.get())->transformOperations(), FloatSize(), ops.get());
blink::WebTransformKeyframe transformKeyframe(keyframes[i]->offset(), ops.release());
blink::WebTransformAnimationCurve* transformCurve = static_cast<blink::WebTransformAnimationCurve*>(&curve);
addKeyframeWithTimingFunction(*transformCurve, transformKeyframe, keyframeTimingFunction);
break;
}
default:
ASSERT_NOT_REACHED();
}
}
}
示例2: keyframes
TEST_F(KeyframeEffectModelTest, EvenlyDistributed3)
{
KeyframeVector keyframes(12);
keyframes[0] = AnimatableValueKeyframe::create();
keyframes[0]->setOffset(0);
keyframes[1] = AnimatableValueKeyframe::create();
keyframes[2] = AnimatableValueKeyframe::create();
keyframes[3] = AnimatableValueKeyframe::create();
keyframes[4] = AnimatableValueKeyframe::create();
keyframes[4]->setOffset(0.5);
keyframes[5] = AnimatableValueKeyframe::create();
keyframes[6] = AnimatableValueKeyframe::create();
keyframes[7] = AnimatableValueKeyframe::create();
keyframes[7]->setOffset(0.8);
keyframes[8] = AnimatableValueKeyframe::create();
keyframes[9] = AnimatableValueKeyframe::create();
keyframes[10] = AnimatableValueKeyframe::create();
keyframes[11] = AnimatableValueKeyframe::create();
const KeyframeVector result = normalizedKeyframes(keyframes);
EXPECT_EQ(12U, result.size());
EXPECT_DOUBLE_EQ(0.0, result[0]->offset());
EXPECT_DOUBLE_EQ(0.125, result[1]->offset());
EXPECT_DOUBLE_EQ(0.25, result[2]->offset());
EXPECT_DOUBLE_EQ(0.375, result[3]->offset());
EXPECT_DOUBLE_EQ(0.5, result[4]->offset());
EXPECT_DOUBLE_EQ(0.6, result[5]->offset());
EXPECT_DOUBLE_EQ(0.7, result[6]->offset());
EXPECT_DOUBLE_EQ(0.8, result[7]->offset());
EXPECT_DOUBLE_EQ(0.85, result[8]->offset());
EXPECT_DOUBLE_EQ(0.9, result[9]->offset());
EXPECT_DOUBLE_EQ(0.95, result[10]->offset());
EXPECT_DOUBLE_EQ(1.0, result[11]->offset());
}
示例3: normalizedKeyframes
KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes)
{
double lastOffset = 0;
KeyframeVector result;
result.reserveCapacity(keyframes.size());
for (size_t i = 0; i < keyframes.size(); ++i) {
double offset = keyframes[i]->offset();
if (!isNull(offset)) {
ASSERT(offset >= 0);
ASSERT(offset <= 1);
ASSERT(offset >= lastOffset);
lastOffset = offset;
}
result.append(keyframes[i]->clone());
}
if (result.isEmpty()) {
return result;
}
if (isNull(result.last()->offset()))
result.last()->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result[0]->setOffset(0);
size_t lastIndex = 0;
lastOffset = result[0]->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffset) * j / (i - lastIndex));
lastIndex = i;
lastOffset = offset;
}
}
return result;
}
示例4:
KeyframeEffectModelBase::KeyframeVector
KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes) {
double lastOffset = 0;
KeyframeVector result;
result.reserveCapacity(keyframes.size());
for (const auto& keyframe : keyframes) {
double offset = keyframe->offset();
if (!isNull(offset)) {
DCHECK_GE(offset, 0);
DCHECK_LE(offset, 1);
DCHECK_GE(offset, lastOffset);
lastOffset = offset;
}
result.push_back(keyframe->clone());
}
if (result.isEmpty())
return result;
if (isNull(result.back()->offset()))
result.back()->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result.front()->setOffset(0);
size_t lastIndex = 0;
lastOffset = result.front()->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(
lastOffset + (offset - lastOffset) * j / (i - lastIndex));
lastIndex = i;
lastOffset = offset;
}
}
return result;
}
示例5: keyframes
TEST_F(KeyframeEffectModelTest, LastOne)
{
KeyframeEffectModel::KeyframeVector keyframes(3);
keyframes[0] = Keyframe::create();
keyframes[0]->setOffset(-1);
keyframes[1] = Keyframe::create();
keyframes[2] = Keyframe::create();
keyframes[2]->setOffset(2);
const KeyframeVector result = normalizedKeyframes(keyframes);
EXPECT_EQ(1U, result.size());
EXPECT_DOUBLE_EQ(1.0, result[0]->offset());
}
示例6: trainSURFMatcher
void trainSURFMatcher(
const KeyframeVector& keyframes,
cv::FlannBasedMatcher& matcher)
{
std::vector<cv::Mat> descriptors_vector;
for (unsigned int kf_idx = 0; kf_idx < keyframes.size(); ++kf_idx)
{
const RGBDKeyframe& keyframe = keyframes[kf_idx];
descriptors_vector.push_back(keyframe.descriptors);
}
matcher.add(descriptors_vector);
matcher.train();
}
示例7: saveKeyframes
bool saveKeyframes(
const KeyframeVector& keyframes,
const std::string& path)
{
for (unsigned int kf_idx = 0; kf_idx < keyframes.size(); ++kf_idx)
{
std::stringstream ss_idx;
ss_idx << std::setw(4) << std::setfill('0') << kf_idx;
std::string kf_path = path + "/" + ss_idx.str();
bool save_result = RGBDKeyframe::save(keyframes[kf_idx], kf_path);
if (!save_result) return false;
}
return true;
}
示例8: normalizedKeyframes
KeyframeEffectModelBase::KeyframeVector KeyframeEffectModelBase::normalizedKeyframes(const KeyframeVector& keyframes)
{
// keyframes [beginIndex, endIndex) will remain after removing all keyframes if they are not
// loosely sorted by offset, and after removing keyframes with positional offset outide [0, 1].
size_t beginIndex = 0;
size_t endIndex = keyframes.size();
// Becomes the most recent keyframe with an explicit offset.
size_t lastIndex = endIndex;
double lastOffset = std::numeric_limits<double>::quiet_NaN();
for (size_t i = 0; i < keyframes.size(); ++i) {
double offset = keyframes[i]->offset();
if (!isNull(offset)) {
if (lastIndex < i && offset < lastOffset) {
// The keyframes are not loosely sorted by offset. Exclude all.
endIndex = beginIndex;
break;
}
if (offset < 0) {
// Remove all keyframes up to and including this keyframe.
beginIndex = i + 1;
} else if (offset > 1) {
// Remove all keyframes from this keyframe onwards. Note we must complete our checking
// that the keyframes are loosely sorted by offset, so we can't exit the loop early.
endIndex = std::min(i, endIndex);
}
lastIndex = i;
lastOffset = offset;
}
}
KeyframeVector result;
if (beginIndex != endIndex) {
result.reserveCapacity(endIndex - beginIndex);
for (size_t i = beginIndex; i < endIndex; ++i) {
result.append(keyframes[i]->clone());
}
if (isNull(result[result.size() - 1]->offset()))
result[result.size() - 1]->setOffset(1);
if (result.size() > 1 && isNull(result[0]->offset()))
result[0]->setOffset(0);
lastIndex = 0;
lastOffset = result[0]->offset();
for (size_t i = 1; i < result.size(); ++i) {
double offset = result[i]->offset();
if (!isNull(offset)) {
if (lastIndex + 1 < i) {
for (size_t j = 1; j < i - lastIndex; ++j)
result[lastIndex + j]->setOffset(lastOffset + (offset - lastOffset) * j / (i - lastIndex));
}
lastIndex = i;
lastOffset = offset;
}
}
}
return result;
}