Clip* Scene::duplicateClip(Clip *c) { Clip *nc = createClip( c->getSource(), c->position(), c->start(), c->length() ); nc->setFrameDuration( profile.getVideoFrameDuration() ); nc->setSpeed( c->getSpeed() ); Transition *t = c->getTransition(); nc->setTransition( t ? new Transition(t) : NULL ); FilterCollection *fc = FilterCollection::getGlobalInstance(); for ( int i = 0; i < c->videoFilters.count(); ++i ) { QSharedPointer<GLFilter> f = c->videoFilters.at( i ); for ( int j = 0; j < fc->videoFilters.count(); ++j ) { if ( fc->videoFilters[ j ].identifier == f->getIdentifier() ) { QSharedPointer<Filter> nf = fc->videoFilters[ j ].create(); f->duplicateFilter( nf ); GLFilter *gf = (GLFilter*)nf.data(); if ( nf->getIdentifier() == "GLCustom" ) { GLCustom *gc = (GLCustom*)gf; gc->setCustomParams( f->getParameters().last()->value.toString() ); } else if ( nf->getIdentifier() == "GLStabilize" ) { GLStabilize *gs = (GLStabilize*)gf; gs->setSource( nc->getSource() ); } nc->videoFilters.append( nf.staticCast<GLFilter>() ); break; } } } for ( int i = 0; i < c->audioFilters.count(); ++i ) { QSharedPointer<AudioFilter> f = c->audioFilters.at( i ); for ( int j = 0; j < fc->audioFilters.count(); ++j ) { if ( fc->audioFilters[ j ].identifier == f->getIdentifier() ) { QSharedPointer<Filter> nf = fc->audioFilters[ j ].create(); f->duplicateFilter( nf ); nc->audioFilters.append( nf.staticCast<AudioFilter>() ); break; } } } return nc; }
void Animation::createClips(Properties* animationProperties, unsigned int frameCount) { GP_ASSERT(animationProperties); Properties* pClip = animationProperties->getNextNamespace(); while (pClip != NULL && std::strcmp(pClip->getNamespace(), "clip") == 0) { int begin = pClip->getInt("begin"); int end = pClip->getInt("end"); AnimationClip* clip = createClip(pClip->getId(), ((float)begin / frameCount) * _duration, ((float)end / frameCount) * _duration); const char* repeat = pClip->getString("repeatCount"); if (repeat) { if (strcmp(repeat, ANIMATION_INDEFINITE_STR) == 0) { clip->setRepeatCount(AnimationClip::REPEAT_INDEFINITE); } else { float value; sscanf(repeat, "%f", &value); clip->setRepeatCount(value); } } const char* speed = pClip->getString("speed"); if (speed) { float value; sscanf(speed, "%f", &value); clip->setSpeed(value); } clip->setLoopBlendTime(pClip->getFloat("loopBlendTime")); // returns zero if not specified pClip = animationProperties->getNextNamespace(); } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); // Create seed for the random // That is needed only once on application startup QTime time = QTime::currentTime(); qsrand((uint)time.msec()); QDir dir("./"); if(!QDir("images").exists()) dir.mkdir("images"); QFontMetrics fontMetrics(QFont(fontname, nSizeFont)); QRect rectText = fontMetrics.boundingRect("01"); nCountCharsWidth = (nWidth / (rectText.width()/2)) - 1; nCountCharsHeigth = (nHeight / (rectText.height()/2)) - 1; int countclips = (2*60+44) * 30; for(int i=0; i<countclips; i++) { if(i%200 == 0) std::cout << "\ti: " << i << "/" << countclips << "\r\n"; createClip(i, "sea-kg - 01-Neuer (2013 Neuer)"); } /* if( !test_seakgLine() ) return -1; if( !test_seakgRow() ) return -2; if( !test_seakgObject2D() ) return -3; if( !test_seakgObjects2D() ) return -4; //std::cout << "all test completed\n"; //return 0; QString inputFileName, outputFileName; if(argc == 3) { inputFileName = QString(argv[1]); outputFileName = QString(argv[2]); } else std::cout << "usage: cat-coin srcfilename dstfilename "<< std::endl; if (!inputFileName.isEmpty()) { QImage inputImage(inputFileName); if (inputImage.isNull()) { std::cout << "Error load image "<< std::endl; return 1; } QImage outputImage(inputImage.width(), inputImage.height(), QImage::Format_RGB32); //QImage outputImage(inputImage.width(), inputImage.height(), QImage::Format_ARGB32); std::cout << "inputImage.width = " << inputImage.width() << "\n"; std::cout << "inputImage.height = " << inputImage.height() << "\n"; //toWhiteBlack len; //forForPixels(inputImage, outputImage, len); int newWidth, newHeight; { toObjects toObjs; forForPixels(inputImage, outputImage, toObjs); toObjs.objects.refactoring(); seakgObject2D_XY object = toObjs.objects.getMaxFattestOfObject(); object.fillGaps(); int X, Y; object.getCenterOfMass(X, Y); int minX_Y = object.getMinX(Y); int maxX_Y = object.getMaxX(Y); int minY_X = object.getMinY(X); int maxY_X = object.getMaxY(X); int xR = std::max(X - minX_Y, maxX_Y - X); int yR = std::max(Y - minY_X, maxY_X - Y); int R = (xR + yR) / 2; newWidth = R*2; newHeight = R*2; QRgb value; value = qRgb(128,128,128); QRectF rectangle(X - R, Y - R, R*2, R*2); std::cout << "minX_Y = " << minX_Y << " minY_X = " << minY_X << "\n"; std::cout << "maxX_Y = " << maxX_Y << " maxY_X = " << maxY_X << "\n"; QPainter p(&outputImage); { QBrush brush( Qt::white, Qt::SolidPattern); QPen pen(Qt::white); p.setPen(pen); p.setBrush(brush); p.drawRect(0,0,outputImage.width(),outputImage.height()); } { QBrush brush( Qt::black, Qt::SolidPattern); QPen pen(Qt::black); p.setPen(pen); p.setBrush(brush); p.drawEllipse(rectangle); } //outputImage.save(outputFileName + "_2.png"); } QImage outputImage2( newWidth ,newHeight, QImage::Format_ARGB32); { toObjects toObjs; forForPixels(outputImage, outputImage, toObjs); toObjs.objects.refactoring(); seakgObject2D_XY fattestObject = toObjs.objects.getMaxFattestOfObject(); fattestObject.fillGaps(); // std::cout << "count : " int minX, maxX, minY, maxY; fattestObject.getExtremePoints(minX, maxX, minY, maxY); onlyFatObject fatObj(fattestObject, - minX, - minY); forForPixels(inputImage, outputImage2, fatObj); } // saves result outputImage2.save(outputFileName); } * */ return 0; }
/* new scene */ int createScene (pScene sc, int idmesh) { pMesh mesh; char data[128]; /* default */ mesh = cv.mesh[idmesh]; if (!quiet) fprintf(stdout, " Computing 3D scene\n"); /* set default mode */ sc->idmesh = idmesh; sc->par.xi = sc->par.yi = 10; if (option == SCHNAUZER) { sc->par.xs = schw; sc->par.ys = schh; } else { if (sc->par.xs == 0) sc->par.xs = 600; if (sc->par.ys == 0) sc->par.ys = 600; } if (!sc->mode) sc->mode = HIDDEN; sc->item = 0; sc->shrink = 1.0; sc->slave = sc->master = -1; sc->picked = 0; if (mesh->nvn == 0) sc->type ^= S_FLAT; if (mesh->ne == 0) sc->item |= S_GEOM; /* compute scene depth */ sc->dmax = sc->dmin = mesh->xmax - mesh->xmin; sc->dmax = max(sc->dmax, mesh->ymax - mesh->ymin); sc->dmin = min(sc->dmin, mesh->ymax - mesh->ymin); if (mesh->dim == 3) { sc->dmax = max(sc->dmax, mesh->zmax - mesh->zmin); sc->dmin = min(sc->dmin, mesh->zmax - mesh->zmin); } sc->dmax = fabs(sc->dmax); sc->dmin = fabs(sc->dmin); if (!sc->par.sunp) { sc->par.sunpos[0] *= 2.0 * sc->dmax; sc->par.sunpos[1] *= 2.0 * sc->dmax; sc->par.sunpos[2] *= 2.0 * sc->dmax; } sc->par.sunpos[3] = 1.0; /* create window */ glutInitWindowSize(sc->par.xs, sc->par.ys); sc->idwin = glutCreateWindow(""); assert(sc->idwin != 0); if (fullscreen) { glutFullScreen(); sc->par.xs = glutGet(GLUT_SCREEN_WIDTH); sc->par.ys = glutGet(GLUT_SCREEN_HEIGHT); } /* set window name */ sprintf(data, "Medit - [%s] #%d", mesh->name, sc->idwin); glutSetWindowTitle(data); glutSetIconTitle(data); /* required! to change background color */ glClearColor(sc->par.back[0], sc->par.back[1], sc->par.back[2], sc->par.back[3]); /* init perspective */ sc->persp = initPersp(0, sc->dmax); sc->camera = (pCamera)initCamera(sc, Y_AXIS); if (mesh->typ == 2) { sc->persp->pmode = CAMERA; sc->persp->depth *= 0.5; } /* create default view */ sc->view = (pTransform)createTransform(); if (!sc->view) return (0); sc->type |= S_RESET + S_DECO; sc->clip = (pClip)createClip(sc, mesh); if (!sc->clip) return (0); sc->cube = (pCube)createCube(sc, mesh); if (!sc->cube) return (0); /* create menus */ if (!createMenus(sc, mesh)) return (0); /* assign callbacks */ if (sc->type & S_SCISSOR) { glutDisplayFunc(scissorScene); } else if (option == SCHNAUZER) { glutDisplayFunc(redrawSchnauzer); } else if (sc->persp->pmode == CAMERA) { glutMouseFunc(mouseCamera); glutMotionFunc(motionCamera); glutDisplayFunc(redrawScene); } else { glutMouseFunc(mouse); glutMotionFunc(motion); glutDisplayFunc(redrawScene); } glutReshapeFunc(reshapeScene); glutKeyboardFunc(keyScene); glutSpecialFunc(special); glutAttachMenu(GLUT_RIGHT_BUTTON); /* create display lists by geom type */ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); doLists(sc, mesh); sc->glist = geomList(sc, mesh); sc->type |= S_FOLLOW; /* local stack */ if (!pilmat) { pilmat = (int *)calloc(sc->par.nbmat + 2, sizeof(int)); if (!pilmat) return (0); } /* color list */ setupPalette(sc, mesh); sc->stream = NULL; initGrafix(sc, mesh); return (1); }
Clip* Scene::sceneSplitClip( Clip *clip, int track, double pts ) { pts = nearestPTS( pts, profile.getVideoFrameDuration() ); double start = clip->position(); if (clip->getTransition()) { start += clip->getTransition()->length(); } double end = clip->position() + clip->length(); Track *t = tracks[track]; int cc = t->clipCount(); int index = t->indexOf(clip); Transition *tail = NULL; Clip *next = NULL; if (index > -1 && index < cc - 1) { next = t->clipAt(index + 1); if (next->getTransition()) { end -= next->getTransition()->length() + profile.getVideoFrameDuration(); tail = new Transition(next->getTransition()); } } double oldLength = clip->length(); double newLength = pts - clip->position(); resize( clip, newLength, track ); Clip *nc = createClip( clip->getSource(), pts, clip->start() + newLength, oldLength - newLength ); double newPos = nc->position(); nc->setPosition( newPos ); FilterCollection *fc = FilterCollection::getGlobalInstance(); for ( int i = 0; i < clip->videoFilters.count(); ++i ) { QSharedPointer<GLFilter> f = clip->videoFilters.at( i ); for ( int j = 0; j < fc->videoFilters.count(); ++j ) { if ( fc->videoFilters[ j ].identifier == f->getIdentifier() ) { QSharedPointer<Filter> nf = fc->videoFilters[ j ].create(); GLFilter *gf = (GLFilter*)nf.data(); if ( nf->getIdentifier() == "GLCustom" ) { GLCustom *gc = (GLCustom*)gf; gc->setCustomParams( f->getParameters().last()->value.toString() ); } else if ( nf->getIdentifier() == "GLStabilize" ) { GLStabilize *gs = (GLStabilize*)gf; gs->setSource( nc->getSource() ); } f->splitParameters( gf, newLength ); nf->setPosition( nc->position() ); nf->setLength( nc->length() ); nc->videoFilters.append( nf.staticCast<GLFilter>() ); break; } } } for ( int i = 0; i < clip->audioFilters.count(); ++i ) { QSharedPointer<AudioFilter> f = clip->audioFilters.at( i ); for ( int j = 0; j < fc->audioFilters.count(); ++j ) { if ( fc->audioFilters[ j ].identifier == f->getIdentifier() ) { QSharedPointer<Filter> nf = fc->audioFilters[ j ].create(); AudioFilter *af = (AudioFilter*)nf.data(); f->splitParameters( af, newLength ); nf->setPosition( nc->position() ); nf->setLength( nc->length() ); nc->audioFilters.append( nf.staticCast<AudioFilter>() ); break; } } } addClip( nc, track ); if (tail) { next->setTransition(tail); } return nc; }