本文整理汇总了C++中SegmentList::size方法的典型用法代码示例。如果您正苦于以下问题:C++ SegmentList::size方法的具体用法?C++ SegmentList::size怎么用?C++ SegmentList::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SegmentList
的用法示例。
在下文中一共展示了SegmentList::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawInputSegments
void drawInputSegments(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0,0.0,0.0);
glPointSize(3.0);
cout << segments.size() << endl;
for (int i = 0; i < segments.size(); i++){
glBegin(GL_LINES);
glVertex2d(segments[i].p1[0], segments[i].p1[1]);
glVertex2d(segments[i].p2[0], segments[i].p2[1]);
glEnd();
glFlush();
}
}
示例2: updateDeltasForContainingBlockLine
void ShapeOutsideInfo::updateDeltasForContainingBlockLine(const RenderBlockFlow& containingBlock, const FloatingObject& floatingObject, LayoutUnit lineTop, LayoutUnit lineHeight)
{
LayoutUnit borderBoxTop = containingBlock.logicalTopForFloat(&floatingObject) + containingBlock.marginBeforeForChild(&m_renderer);
LayoutUnit borderBoxLineTop = lineTop - borderBoxTop;
if (isShapeDirty() || m_borderBoxLineTop != borderBoxLineTop || m_lineHeight != lineHeight) {
m_borderBoxLineTop = borderBoxLineTop;
m_referenceBoxLineTop = borderBoxLineTop - logicalTopOffset();
m_lineHeight = lineHeight;
LayoutUnit floatMarginBoxWidth = containingBlock.logicalWidthForFloat(&floatingObject);
if (lineOverlapsShapeBounds()) {
SegmentList segments = computeSegmentsForLine(borderBoxLineTop, lineHeight);
if (segments.size()) {
LayoutUnit logicalLeftMargin = containingBlock.style()->isLeftToRightDirection() ? containingBlock.marginStartForChild(&m_renderer) : containingBlock.marginEndForChild(&m_renderer);
LayoutUnit rawLeftMarginBoxDelta = segments.first().logicalLeft + logicalLeftMargin;
m_leftMarginBoxDelta = clampToLayoutUnit(rawLeftMarginBoxDelta, LayoutUnit(), floatMarginBoxWidth);
LayoutUnit logicalRightMargin = containingBlock.style()->isLeftToRightDirection() ? containingBlock.marginEndForChild(&m_renderer) : containingBlock.marginStartForChild(&m_renderer);
LayoutUnit rawRightMarginBoxDelta = segments.last().logicalRight - containingBlock.logicalWidthForChild(&m_renderer) - logicalRightMargin;
m_rightMarginBoxDelta = clampToLayoutUnit(rawRightMarginBoxDelta, -floatMarginBoxWidth, LayoutUnit());
m_lineOverlapsShape = true;
return;
}
}
// Lines that do not overlap the shape should act as if the float
// wasn't there for layout purposes. So we set the deltas to remove the
// entire width of the float.
m_leftMarginBoxDelta = floatMarginBoxWidth;
m_rightMarginBoxDelta = -floatMarginBoxWidth;
m_lineOverlapsShape = false;
}
}
示例3: decompose
SegmentList WaterShedDecomposer::decompose(ImageColor const & image) const {
QTime time;
time.start();
// original image
image.save("WS1_original.png");
// filter image
time.restart();
ImageColor filtered = filterGauss(image, radiusGauss->value());
qDebug("Image filtered in %g seconds", time.restart()/1000.0);
filtered.save("WS2_filtered.png");
// calculate gradient magnitude map
time.restart();
ImageGray gradientMap = gradientMagnitude(filtered);
qDebug("Gradient magnitude map calculated in %g seconds", time.restart()/1000.0);
gradientMap.save("WS3_gradient.png");
// apply watershed transformation
time.restart();
SegmentList segments = watershed(gradientMap, image);
qDebug("Watershed transformation applied in %g seconds", time.restart()/1000.0);
qDebug(" Segments: %d", segments.size());
ImageColor debugOut(image.width(), image.height());
segments.copyToImageAVG(debugOut);
debugOut.save("WS4_transformed.png");
// merge similiar and small segments
time.restart();
int oldSegmentsSize;
do {
oldSegmentsSize = segments.size();
mergeSimiliarSegments(segments, epsilonMerge->value()*epsilonMerge->value());
mergeSmallSegments(segments, minSize->value());
} while (segments.size() != oldSegmentsSize);
qDebug("Segments merged in %g seconds", time.restart()/1000.0);
qDebug(" Segments: %d", segments.size());
segments.copyToImageAVG(debugOut);
debugOut.save("WS5_merged.png");
return segments;
}
示例4: computeSegmentsForLine
SegmentList ShapeOutsideInfo::computeSegmentsForLine(LayoutUnit lineTop, LayoutUnit lineHeight) const
{
ASSERT(lineHeight >= 0);
SegmentList segments;
computedShape().getExcludedIntervals((lineTop - logicalTopOffset()), std::min(lineHeight, shapeLogicalBottom() - lineTop), segments);
for (size_t i = 0; i < segments.size(); i++) {
segments[i].logicalLeft += logicalLeftOffset();
segments[i].logicalRight += logicalLeftOffset();
}
return segments;
}
示例5: Optimise
/// Optimise a track trajectory
void Trajectory::Optimise(SegmentList track, int max_iter, float alpha, const char* fname, bool reset)
{
int N = track.size();
clock_t start_time = clock();
int min_iter = max_iter/2; // minimum number of iterations to do
float time_limit = 2.0f; // if more than min_iter have been done, exit when time elapsed is larger than the time limit
float beta = 0.75f; // amount to reduce alpha to when it seems to be too large
w.resize(N);
dw.resize(N);
dw2.resize(N);
indices.resize(N);
accel.resize(N);
// initialise vectors
int i;
for (i=0; i<N; ++i) {
if (reset) {w[i] = 0.5f;}
dw2[i] = 1.0f;
indices[i] = i;
}
// Shuffle thoroughly
#if 1
srand(12358);
for (i=0; i<N-1; ++i) {
int z = rand()%(N-i);
int tmp = indices[i];
indices[i] = indices[z+i];
indices[z+i] = tmp;
}
#endif
float prevC = 0.0f;
float Z = 10.0f;
float lambda = 0.9f;
float delta_C = 0.0f;
float prev_dCdw2 = 0.0f;
for (int iter=0; iter<max_iter; iter++) {
float C = 0.0f;
float P = 0.0f;
float dCdw2 = 0.0f;
float EdCdw = 0.0f;
float direction = 0.0;
for (int j=0; j<N-1; ++j) {
int i = indices[j];//rand()%(N-3) + 3;
int i_p3 = i - 3;
if (i_p3 < 0) i_p3 +=N;
int i_p2 = i - 2;
if (i_p2 < 0) i_p2 +=N;
int i_p1 = i - 1;
if (i_p1 < 0) i_p1 +=N;
//int i_n3 = (i + 3)%N;
int i_n2 = (i + 2)%N;
int i_n1 = (i + 1)%N;
Segment s_prv3 = track[i_p3];
Segment s_prv2 = track[i_p2];
Segment s_prv = track[i_p1];
Segment s_cur = track[i];
Segment s_nxt = track[i_n1];
Segment s_nxt2 = track[i_n2];
Point prv3 = GetPoint(track[i_p3], w[i_p3]);
Point prv2 = GetPoint(track[i_p2], w[i_p2]);
Point prv = GetPoint(track[i_p1], w[i_p1]);
Point cur = GetPoint(track[i], w[i]);
Point nxt = GetPoint(track[i_n1], w[i_n1]);
Point nxt2 = GetPoint(track[i_n2], w[i_n2]);
Point u_prv2 = prv2 - prv3;
Point u_prv = prv - prv2;
Point u_cur = cur - prv;
Point u_nxt = nxt - cur;
Point u_nxt2 = nxt2 - nxt;
u_prv.Normalise();
u_cur.Normalise();
u_nxt.Normalise();
u_nxt2.Normalise();
//float l_prv2 = (prv2 - prv3).Length();
float l_prv = (prv - prv2).Length();
float l_cur = (cur - prv).Length();
float l_nxt = (nxt - cur).Length();
#if 1
Point a_prv = (u_cur - u_prv)/l_prv;
Point a_cur = (u_nxt - u_cur)/l_cur;
Point a_nxt = (u_nxt2 - u_nxt)/l_nxt;
#else
Point a_prv = (u_prv - u_prv2)/l_prv2;
Point a_cur = (u_cur - u_prv)/l_prv;
Point a_nxt = (u_nxt - u_cur)/l_cur;
#endif
float current_cost = a_prv.Length()*a_prv.Length()
+ a_cur.Length()*a_cur.Length()
+ a_nxt.Length()*a_nxt.Length();
//accel[i] = +a_nxt.Length();
accel[i] = (a_prv.Length() + a_cur.Length() + a_nxt.Length())/3.0f;
//.........这里部分代码省略.........