//--------------------------------------------------------------------------- void tTJSLocalNamespace::Pop(void) { #ifdef TJS_DEBUG_PROFILE_TIME tTJSTimeProfiler prof(time_ns_Pop); #endif tTJSLocalSymbolList * list= Levels[Levels.size()-1]; Commit(); CurrentCount= list->GetLocalCountStart(); Levels.pop_back(); delete list; }
static VEC SubProf( // return the profile at given offset within fullprof int offset, // in: offset along whisker in pixels int proflen, // in const VEC& fullprof) // in { CV_Assert(proflen > 1 && proflen < 100); // 100 is arb CV_Assert(proflen % 2 == 1); // prof length must be odd VEC prof(1, proflen); // the profile at the given offset along whisker // copy the relevant part of fullprof into prof memcpy(Buf(prof), Buf(fullprof) + offset + NSIZE(fullprof)/2 - NSIZE(prof)/2, NSIZE(prof) * sizeof(prof(0))); // normalize prof double sum = SumAbsElems(prof); if (!IsZero(sum)) prof *= NSIZE(prof) / sum; return prof; }
void ProfileManager::updateProfile(const QString ¤t, const QString &profile) { if (current == profile) { return; } Updater::Version prof(profile); if (prof == Updater::Version("1.0.0")) { update100(); return; } if (prof == Updater::Version("1.1.0") || prof == Updater::Version("1.1.5") || prof == Updater::Version("1.1.8")) { update118(); return; } if (prof == Updater::Version("1.2.0")) { update120(); return; } if (prof == Updater::Version("1.3.0") || prof == Updater::Version("1.3.1")) { update130(); return; } if (prof >= Updater::Version("1.4.0") && prof <= Updater::Version("1.5.0")) { update140(); return; } if (prof >= Updater::Version("1.6.0") && prof < Updater::Version("1.8.0")) { update160(); return; } if (prof >= Updater::Version("1.8.0") && prof < Updater::Version("1.9.0")) { // do nothing return; } std::cout << "QupZilla: Incompatible profile version detected (" << qPrintable(profile) << "), overwriting profile data..." << std::endl; copyDataToProfile(); }
//--------------------------------------------------------------------------- void tTJSLocalNamespace::Remove(const tjs_char *name) { #ifdef TJS_DEBUG_PROFILE_TIME tTJSTimeProfiler prof(time_ns_Remove); #endif tjs_int i; for(i=Levels.size()-1; i>=0; i--) { tTJSLocalSymbolList* list = Levels[i]; tjs_int lidx = list->Find(name); if(lidx!=-1) { list->Remove(name); return; } } }
//--------------------------------------------------------------------------- tjs_int tTJSLocalNamespace::Find(const tjs_char *name) { #ifdef TJS_DEBUG_PROFILE_TIME tTJSTimeProfiler prof(time_ns_Find); #endif // search "name" tjs_int i; /* signed */ for(i=Levels.size()-1; i>=0; i--) { tTJSLocalSymbolList* list = Levels[i]; tjs_int lidx = list->Find(name); if(lidx!=-1) { lidx += list->GetLocalCountStart(); return lidx; } } return -1; }
void Imprimir_graficos::mostprof() { pasgs = 0; pcmps = 0; plns = 0; QTime tiempo(0, 0, 0, 0); int t = 0; ui->listacts->clear(); tiempo.start(); // Llamada al metodo recursivo de profundidad prof(g->vertinicio, 0); t = tiempo.elapsed(); plns += pasgs + pcmps; ui->listacts->addItem(QString::fromStdString(g->rutac)); ui->recasg->setText(QString::number(pasgs)); ui->reccmp->setText(QString::number(pcmps)); ui->reclns->setText(QString::number(plns)); ui->rectmp->setText(QString::number(t) + " ms."); }
void NegativeProcessor::setCameraProfile(const char *dcpFilename) { AutoPtr<dng_camera_profile> prof(new dng_camera_profile); if (strlen(dcpFilename) > 0) { dng_file_stream profStream(dcpFilename); if (!prof->ParseExtended(profStream)) throw std::runtime_error("Could not parse supplied camera profile file!"); } else { // ----------------------------------------------------------------------------------------- // Build our own minimal profile, based on one colour matrix provided by LibRaw dng_string profName; profName.Append(m_RawProcessor->imgdata.idata.make); profName.Append(" "); profName.Append(m_RawProcessor->imgdata.idata.model); prof->SetName(profName.Get()); prof->SetCalibrationIlluminant1(lsD65); int colors = m_RawProcessor->imgdata.idata.colors; if ((colors == 3) || (colors = 4)) { dng_matrix *colormatrix1 = new dng_matrix(colors, 3); for (int i = 0; i < colors; i++) for (int j = 0; j < 3; j++) (*colormatrix1)[i][j] = m_RawProcessor->imgdata.color.cam_xyz[i][j]; if (colormatrix1->MaxEntry() == 0.0) { printf("Warning, camera XYZ Matrix is null\n"); delete colormatrix1; if (colors == 3) colormatrix1 = new dng_matrix_3by3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); else colormatrix1 = new dng_matrix_4by3(0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); } prof->SetColorMatrix1(*colormatrix1); } prof->SetProfileCalibrationSignature("com.fimagena.raw2dng"); } m_negative->AddProfile(prof); }
void WindowsConfigurator::run() { if ((this->templateDir = (*this->config)[WindowsProfile::CONFIG_PROFILE_TEMPLATE]).length() == 0) { std::cout << "Profile template directory not configured." << std::endl; throw std::runtime_error("Bad configuration of 'Profile_Template'"); } /* Check the template directory exists and is valid. */ WindowsProfile prof("", this->templateDir); if (!prof.valid()) { std::cout << "Profile directory error: " << prof.getLastError() << std::endl; throw std::runtime_error("Profile with profile template directory"); } /* Start server. */ this->server->loop(); }
int main (int argc, char** argv) { Profiler prof(argv[0]); int ndim = 3; char* infile = nullptr; IFEM::Init(argc,argv,"Cahn-Hilliard equation solver"); for (int i = 1; i < argc; i++) if (SIMoptions::ignoreOldOptions(argc,argv,i)) ; // ignore the obsolete option else if (!strcmp(argv[i],"-2D")) ndim = 2; else if (!strcmp(argv[i],"-1D")) ndim = 1; else if (!infile) infile = argv[i]; else std::cerr <<" ** Unknown option ignored: "<< argv[i] << std::endl; if (!infile) { std::cout <<"usage: "<< argv[0] <<" <inputfile> [-dense|-spr|-superlu[<nt>]|-samg|-petsc]\n" <<" [-lag|-spec|-LR] [-1D|-2D] [-nGauss <n>] [-fourth]\n" <<" [-vtf <format> [-nviz <nviz>]" <<" [-nu <nu>] [-nv <nv>] [-nw <nw>]] [-hdf5]"<< std::endl; return 0; } IFEM::cout <<"\nInput file: "<< infile; IFEM::getOptions().print(IFEM::cout); IFEM::cout << std::endl; if (ndim == 3) return runSimulator<SIM3D>(infile); else if (ndim == 2) return runSimulator<SIM2D>(infile); else return runSimulator<SIM1D>(infile); }
static inline PDSize PDHashGeneratorCString(const char *key) { prof(cstring_hashgens++); // from http://c.learncodethehardway.org/book/ex37.html size_t len = strlen(key); PDSize hash = 0; PDSize i = 0; for(hash = i = 0; i < len; ++i) { hash += key[i]; hash += (hash << 10); hash ^= (hash >> 6); } hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); return hash; }
int fortosi_new_1::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: startread(); break; case 1: requestCustomers(); break; case 2: next(); break; case 3: back(); break; case 4: tableclicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 5: prof(); break; case 6: onTypeChar(); break; case 7: change_language((*reinterpret_cast< int(*)>(_a[1]))); break; default: ; } _id -= 8; } return _id; }
void QQmlBoundSignal_callback(QQmlNotifierEndpoint *e, void **a) { QQmlBoundSignal *s = static_cast<QQmlBoundSignal*>(e); if (!s->m_expression) return; QV4DebugService *service = QQmlDebugConnector::service<QV4DebugService>(); if (service) service->signalEmitted(QString::fromLatin1(QMetaObjectPrivate::signal( s->m_expression->target()->metaObject(), s->signalIndex()).methodSignature())); QQmlEngine *engine; if (s->m_expression && (engine = s->m_expression->engine())) { QQmlHandlingSignalProfiler prof(QQmlEnginePrivate::get(engine)->profiler, s->m_expression); s->m_expression->evaluate(a); if (s->m_expression && s->m_expression->hasError()) { QQmlEnginePrivate::warning(engine, s->m_expression->error(engine)); } } }
void QQmlBoundSignal_callback(QQmlNotifierEndpoint *e, void **a) { QQmlBoundSignal *s = static_cast<QQmlBoundSignal*>(e); if (!s->m_expression) return; if (QQmlDebugService::isDebuggingEnabled()) QV4DebugService::instance()->signalEmitted(QString::fromLatin1(QMetaObjectPrivate::signal(s->m_expression->target()->metaObject(), s->m_index).methodSignature())); s->m_isEvaluating = true; QQmlEngine *engine; if (s->m_expression && (engine = s->m_expression->engine())) { QQmlHandlingSignalProfiler prof(QQmlEnginePrivate::get(engine)->profiler, s->m_expression); s->m_expression->evaluate(a); if (s->m_expression && s->m_expression->hasError()) { QQmlEnginePrivate::warning(engine, s->m_expression->error(engine)); } } s->m_isEvaluating = false; }
int main() { int i,j; for(i=0;i<n;i++) for(j=0;j<n;j++) GRAPHE[i][j] = 0; GRAPHE[0][0] = 1; GRAPHE[0][1] = 1; GRAPHE[0][2] = 1; GRAPHE[1][3] = 1; GRAPHE[2][0] = 1; GRAPHE[2][1] = 1; GRAPHE[2][4] = 1; GRAPHE[3][2] = 1; GRAPHE[3][4] = 1; GRAPHE[4][1] = 1; for(i=0;i<n;i++) M[i] = 0; printf("->1\n"); prof(1,GRAPHE,M); for(i=0;i<n;i++) M[i] = 0; printf("\n->2\n"); prof(2,GRAPHE,M); for(i=0;i<n;i++) M[i] = 0; printf("\n->3\n"); prof(3,GRAPHE,M); for(i=0;i<n;i++) M[i] = 0; printf("\n->4\n"); prof(4,GRAPHE,M); for(i=0;i<n;i++) M[i] = 0; printf("\n->5\n"); prof(5,GRAPHE,M); for(i=0;i<n;i++) M[i] = 0; printf("\n->6\n"); prof(6,GRAPHE,M); printf("\n"); return 0; }
int main(int argc, char *argv[]) { if (argc < 2) { std::cerr << "Usage: " << argv[0] << " <problem.dat>" << std::endl; return 1; } amgcl::profiler<> prof(argv[0]); // Read matrix and rhs from a binary file. std::vector<int> row; std::vector<int> col; std::vector<real> val; std::vector<real> rhs; int n = read_problem(argv[1], row, col, val, rhs); // Initialize VexCL context. vex::Context ctx( vex::Filter::Env && vex::Filter::DoublePrecision ); if (!ctx.size()) { std::cerr << "No GPUs" << std::endl; return 1; } std::cout << ctx << std::endl; // Wrap the matrix into amgcl::sparse::map: amgcl::sparse::matrix_map<real, int> A( n, n, row.data(), col.data(), val.data() ); // Build the preconditioner. typedef amgcl::solver< real, int, amgcl::interp::smoothed_aggregation<amgcl::aggr::plain>, amgcl::level::vexcl > AMG; typename AMG::params prm; // Provide vex::Context for level construction: prm.level.ctx = &ctx; // Use K-Cycle on each level to improve convergence: prm.level.kcycle = 1; prof.tic("setup"); AMG amg(A, prm); prof.toc("setup"); std::cout << amg << std::endl; // Copy matrix and rhs to GPU(s). vex::SpMat<real, int, int> Agpu( ctx.queue(), n, n, row.data(), col.data(), val.data() ); vex::vector<real> f(ctx.queue(), rhs); // Solve the problem with CG method. Use AMG as a preconditioner: vex::vector<real> x(ctx.queue(), n); x = 0; prof.tic("solve (cg)"); auto cnv = amgcl::solve(Agpu, f, amg, x, amgcl::cg_tag()); prof.toc("solve (cg)"); std::cout << "Iterations: " << std::get<0>(cnv) << std::endl << "Error: " << std::get<1>(cnv) << std::endl << std::endl; std::cout << prof; }
int DNGWriter::convert() { d->cancel = false; try { if (inputFile().isEmpty()) { kDebug( 51000 ) << "DNGWriter: No input file to convert. Aborted..." << endl; return -1; } QFileInfo inputInfo(inputFile()); QString dngFilePath = outputFile(); if (dngFilePath.isEmpty()) { dngFilePath = QString(inputInfo.baseName() + QString(".dng")); } QFileInfo outputInfo(dngFilePath); QByteArray rawData; DcrawInfoContainer identify; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: Loading RAW data from " << inputInfo.fileName() << endl; KDcraw rawProcessor; if (!rawProcessor.extractRAWData(inputFile(), rawData, identify)) { kDebug( 51000 ) << "DNGWriter: Loading RAW data failed. Aborted..." << endl; return -1; } if (d->cancel) return -2; int width = identify.imageSize.width(); int height = identify.imageSize.height(); int pixelRange = 16; kDebug( 51000 ) << "DNGWriter: Raw data loaded:" << endl; kDebug( 51000 ) << "--- Data Size: " << rawData.size() << " bytes" << endl; kDebug( 51000 ) << "--- Date: " << identify.dateTime.toString(Qt::ISODate) << endl; kDebug( 51000 ) << "--- Make: " << identify.make << endl; kDebug( 51000 ) << "--- Model: " << identify.model << endl; kDebug( 51000 ) << "--- Size: " << width << "x" << height << endl; kDebug( 51000 ) << "--- Orientation: " << identify.orientation << endl; kDebug( 51000 ) << "--- Top margin: " << identify.topMargin << endl; kDebug( 51000 ) << "--- Left margin: " << identify.leftMargin << endl; kDebug( 51000 ) << "--- Filter: " << identify.filterPattern << endl; kDebug( 51000 ) << "--- Colors: " << identify.rawColors << endl; kDebug( 51000 ) << "--- Black: " << identify.blackPoint << endl; kDebug( 51000 ) << "--- White: " << identify.whitePoint << endl; kDebug( 51000 ) << "--- CAM->XYZ:" << endl; QString matrixVal; for(int i=0; i<12; i+=3) { kDebug( 51000 ) << " " << QString().sprintf("%03.4f %03.4f %03.4f", identify.cameraXYZMatrix[0][ i ], identify.cameraXYZMatrix[0][i+1], identify.cameraXYZMatrix[0][i+2]) << endl; } // Check if CFA layout is supported by DNG SDK. int bayerMosaic; if (identify.filterPattern == QString("GRBGGRBGGRBGGRBG")) { bayerMosaic = 0; } else if (identify.filterPattern == QString("RGGBRGGBRGGBRGGB")) { bayerMosaic = 1; } else if (identify.filterPattern == QString("BGGRBGGRBGGRBGGR")) { bayerMosaic = 2; } else if (identify.filterPattern == QString("GBRGGBRGGBRGGBRG")) { bayerMosaic = 3; } else { kDebug( 51000 ) << "DNGWriter: Bayer mosaic not supported. Aborted..." << endl; return -1; } // Check if number of Raw Color components is supported. if (identify.rawColors != 3) { kDebug( 51000 ) << "DNGWriter: Number of Raw color components not supported. Aborted..." << endl; return -1; } /* // NOTE: code to hack RAW data extraction QString rawdataFilePath(inputInfo.baseName() + QString(".dat")); QFileInfo rawdataInfo(rawdataFilePath); QFile rawdataFile(rawdataFilePath); if (!rawdataFile.open(QIODevice::WriteOnly)) { kDebug( 51000 ) << "DNGWriter: Cannot open file to write RAW data. Aborted..." << endl; return -1; } QDataStream rawdataStream(&rawdataFile); rawdataStream.writeRawData(rawData.data(), rawData.size()); rawdataFile.close(); */ // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: Formating RAW data to memory" << endl; std::vector<unsigned short> raw_data; raw_data.resize(rawData.size()); const unsigned short* dp = (const unsigned short*)rawData.data(); for (uint i = 0; i < raw_data.size()/2; i++) { raw_data[i] = *dp; *dp++; } if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: DNG memory allocation and initialization" << endl; dng_memory_allocator memalloc(gDefaultDNGMemoryAllocator); dng_memory_stream stream(memalloc); stream.Put(&raw_data.front(), raw_data.size()*sizeof(unsigned short)); dng_rect rect(height, width); DNGWriterHost host(d, &memalloc); // Unprocessed raw data. host.SetKeepStage1(true); // Linearized, tone curve processed data. host.SetKeepStage2(true); AutoPtr<dng_image> image(new dng_simple_image(rect, 1, ttShort, 1<<pixelRange, memalloc)); if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: DNG IFD structure creation" << endl; dng_ifd ifd; ifd.fUsesNewSubFileType = true; ifd.fNewSubFileType = 0; ifd.fImageWidth = width; ifd.fImageLength = height; ifd.fBitsPerSample[0] = pixelRange; ifd.fBitsPerSample[1] = 0; ifd.fBitsPerSample[2] = 0; ifd.fBitsPerSample[3] = 0; ifd.fCompression = ccUncompressed; ifd.fPredictor = 1; ifd.fCFALayout = 1; // Rectangular (or square) layout. ifd.fPhotometricInterpretation = piCFA; ifd.fFillOrder = 1; ifd.fOrientation = identify.orientation; ifd.fSamplesPerPixel = 1; ifd.fPlanarConfiguration = 1; ifd.fXResolution = 0.0; ifd.fYResolution = 0.0; ifd.fResolutionUnit = 0; ifd.fUsesStrips = true; ifd.fUsesTiles = false; ifd.fTileWidth = width; ifd.fTileLength = height; ifd.fTileOffsetsType = 4; ifd.fTileOffsetsCount = 0; ifd.fSubIFDsCount = 0; ifd.fSubIFDsOffset = 0; ifd.fExtraSamplesCount = 0; ifd.fSampleFormat[0] = 1; ifd.fSampleFormat[1] = 1; ifd.fSampleFormat[2] = 1; ifd.fSampleFormat[3] = 1; ifd.fLinearizationTableType = 0; ifd.fLinearizationTableCount = 0; ifd.fLinearizationTableOffset = 0; ifd.fBlackLevelRepeatRows = 1; ifd.fBlackLevelRepeatCols = 1; ifd.fBlackLevel[0][0][0] = identify.blackPoint; ifd.fBlackLevelDeltaHType = 0; ifd.fBlackLevelDeltaHCount = 0; ifd.fBlackLevelDeltaHOffset = 0; ifd.fBlackLevelDeltaVType = 0; ifd.fBlackLevelDeltaVCount = 0; ifd.fBlackLevelDeltaVOffset = 0; ifd.fWhiteLevel[0] = identify.whitePoint; ifd.fWhiteLevel[1] = identify.whitePoint; ifd.fWhiteLevel[2] = identify.whitePoint; ifd.fWhiteLevel[3] = identify.whitePoint; ifd.fDefaultScaleH = dng_urational(1, 1); ifd.fDefaultScaleV = dng_urational(1, 1); ifd.fBestQualityScale = dng_urational(1, 1); ifd.fCFARepeatPatternRows = 0; ifd.fCFARepeatPatternCols = 0; ifd.fBayerGreenSplit = 0; ifd.fChromaBlurRadius = dng_urational(0, 0); ifd.fAntiAliasStrength = dng_urational(100, 100); ifd.fActiveArea = rect; ifd.fDefaultCropOriginH = dng_urational(0, 1); ifd.fDefaultCropOriginV = dng_urational(0, 1); ifd.fDefaultCropSizeH = dng_urational(width, 1); ifd.fDefaultCropSizeV = dng_urational(height, 1); ifd.fMaskedAreaCount = 0; ifd.fLosslessJPEGBug16 = false; ifd.fSampleBitShift = 0; ifd.ReadImage(host, stream, *image.Get()); if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: DNG Negative structure creation" << endl; AutoPtr<dng_negative> negative(host.Make_dng_negative()); negative->SetDefaultScale(ifd.fDefaultScaleH, ifd.fDefaultScaleV); negative->SetDefaultCropOrigin(ifd.fDefaultCropOriginH, ifd.fDefaultCropOriginV); negative->SetDefaultCropSize(ifd.fDefaultCropSizeH, ifd.fDefaultCropSizeV); negative->SetActiveArea(ifd.fActiveArea); negative->SetModelName(identify.model.toAscii()); negative->SetLocalName(QString("%1 %2").arg(identify.make).arg(identify.model).toAscii()); negative->SetOriginalRawFileName(inputInfo.fileName().toAscii()); negative->SetColorChannels(3); negative->SetColorKeys(colorKeyRed, colorKeyGreen, colorKeyBlue); negative->SetBayerMosaic(bayerMosaic); negative->SetWhiteLevel(identify.whitePoint, 0); negative->SetWhiteLevel(identify.whitePoint, 1); negative->SetWhiteLevel(identify.whitePoint, 2); negative->SetBlackLevel(identify.blackPoint, 0); negative->SetBlackLevel(identify.blackPoint, 1); negative->SetBlackLevel(identify.blackPoint, 2); negative->SetBaselineExposure(0.0); negative->SetBaselineNoise(1.0); negative->SetBaselineSharpness(1.0); dng_orientation orientation; switch (identify.orientation) { case DcrawInfoContainer::ORIENTATION_180: orientation = dng_orientation::Rotate180(); break; case DcrawInfoContainer::ORIENTATION_90CCW: orientation = dng_orientation::Rotate90CCW(); break; case DcrawInfoContainer::ORIENTATION_90CW: orientation = dng_orientation::Rotate90CW(); break; default: // ORIENTATION_NONE orientation = dng_orientation::Normal(); break; } negative->SetBaseOrientation(orientation); negative->SetAntiAliasStrength(dng_urational(100, 100)); negative->SetLinearResponseLimit(1.0); negative->SetShadowScale( dng_urational(1, 1) ); negative->SetAnalogBalance(dng_vector_3(1.0, 1.0, 1.0)); // ------------------------------------------------------------------------------- // Set Camera->XYZ Color matrix as profile. dng_matrix_3by3 matrix(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); dng_matrix_3by3 camXYZ; AutoPtr<dng_camera_profile> prof(new dng_camera_profile); prof->SetName(QString("%1 %2").arg(identify.make).arg(identify.model).toAscii()); camXYZ[0][0] = identify.cameraXYZMatrix[0][0]; camXYZ[0][1] = identify.cameraXYZMatrix[0][1]; camXYZ[0][2] = identify.cameraXYZMatrix[0][2]; camXYZ[1][0] = identify.cameraXYZMatrix[0][3]; camXYZ[1][1] = identify.cameraXYZMatrix[1][0]; camXYZ[1][2] = identify.cameraXYZMatrix[1][1]; camXYZ[2][0] = identify.cameraXYZMatrix[1][2]; camXYZ[2][1] = identify.cameraXYZMatrix[1][3]; camXYZ[2][2] = identify.cameraXYZMatrix[2][0]; if (camXYZ.MaxEntry() == 0.0) kDebug( 51000 ) << "DNGWriter: Warning, camera XYZ Matrix is null" << endl; else matrix = camXYZ; prof->SetColorMatrix1((dng_matrix) matrix); prof->SetCalibrationIlluminant1(lsD65); negative->AddProfile(prof); // ------------------------------------------------------------------------------- // Clear "Camera WhiteXY" negative->SetCameraWhiteXY(dng_xy_coord()); // This settings break color on preview and thumbnail //negative->SetCameraNeutral(dng_vector_3(1.0, 1.0, 1.0)); if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: Updating metadata to DNG Negative" << endl; dng_exif *exif = negative->GetExif(); exif->fModel.Set_ASCII(identify.model.toAscii()); exif->fMake.Set_ASCII(identify.make.toAscii()); // Time from original shot dng_date_time dt; dt.fYear = identify.dateTime.date().year(); dt.fMonth = identify.dateTime.date().month(); dt.fDay = identify.dateTime.date().day(); dt.fHour = identify.dateTime.time().hour(); dt.fMinute = identify.dateTime.time().minute(); dt.fSecond = identify.dateTime.time().second(); dng_date_time_info dti; dti.SetDateTime(dt); exif->fDateTimeOriginal = dti; exif->fDateTimeDigitized = dti; negative->UpdateDateTime(dti); long int num, den; long val; QString str; KExiv2 meta; if (meta.load(inputFile())) { // String Tags str = meta.getExifTagString("Exif.Image.Software"); if (!str.isEmpty()) exif->fSoftware.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.Image.ImageDescription"); if (!str.isEmpty()) exif->fImageDescription.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.Image.Artist"); if (!str.isEmpty()) exif->fArtist.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.Image.Copyright"); if (!str.isEmpty()) exif->fCopyright.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.Photo.UserComment"); if (!str.isEmpty()) exif->fUserComment.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.Image.CameraSerialNumber"); if (!str.isEmpty()) exif->fCameraSerialNumber.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSLatitudeRef"); if (!str.isEmpty()) exif->fGPSLatitudeRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSLongitudeRef"); if (!str.isEmpty()) exif->fGPSLongitudeRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSSatellites"); if (!str.isEmpty()) exif->fGPSSatellites.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSStatus"); if (!str.isEmpty()) exif->fGPSStatus.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSMeasureMode"); if (!str.isEmpty()) exif->fGPSMeasureMode.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSSpeedRef"); if (!str.isEmpty()) exif->fGPSSpeedRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSTrackRef"); if (!str.isEmpty()) exif->fGPSTrackRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSSpeedRef"); if (!str.isEmpty()) exif->fGPSSpeedRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSImgDirectionRef"); if (!str.isEmpty()) exif->fGPSSpeedRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSMapDatum"); if (!str.isEmpty()) exif->fGPSMapDatum.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSDestLatitudeRef"); if (!str.isEmpty()) exif->fGPSDestLatitudeRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSDestLongitudeRef"); if (!str.isEmpty()) exif->fGPSDestLongitudeRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSDestBearingRef"); if (!str.isEmpty()) exif->fGPSDestBearingRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSDestDistanceRef"); if (!str.isEmpty()) exif->fGPSDestDistanceRef.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSProcessingMethod"); if (!str.isEmpty()) exif->fGPSProcessingMethod.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSAreaInformation"); if (!str.isEmpty()) exif->fGPSAreaInformation.Set_ASCII(str.toAscii()); str = meta.getExifTagString("Exif.GPSInfo.GPSDateStamp"); if (!str.isEmpty()) exif->fGPSDateStamp.Set_ASCII(str.toAscii()); // Rational Tags if (meta.getExifTagRational("Exif.Photo.ExposureTime", num, den)) exif->fExposureTime = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.FNumber", num, den)) exif->fFNumber = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.ShutterSpeedValue", num, den)) exif->fShutterSpeedValue = dng_srational(num, den); if (meta.getExifTagRational("Exif.Photo.ApertureValue", num, den)) exif->fApertureValue = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.BrightnessValue", num, den)) exif->fBrightnessValue = dng_srational(num, den); if (meta.getExifTagRational("Exif.Photo.ExposureBiasValue", num, den)) exif->fExposureBiasValue = dng_srational(num, den); if (meta.getExifTagRational("Exif.Photo.MaxApertureValue", num, den)) exif->fMaxApertureValue = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.FocalLength", num, den)) exif->fFocalLength = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.DigitalZoomRatio", num, den)) exif->fDigitalZoomRatio = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.SubjectDistance", num, den)) exif->fSubjectDistance = dng_urational(num, den); if (meta.getExifTagRational("Exif.Image.BatteryLevel", num, den)) exif->fBatteryLevelR = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.FocalPlaneXResolution", num, den)) exif->fFocalPlaneXResolution = dng_urational(num, den); if (meta.getExifTagRational("Exif.Photo.FocalPlaneYResolution", num, den)) exif->fFocalPlaneYResolution = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSAltitude", num, den)) exif->fGPSAltitude = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSDOP", num, den)) exif->fGPSDOP = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSSpeed", num, den)) exif->fGPSSpeed = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSTrack", num, den)) exif->fGPSTrack = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSImgDirection", num, den)) exif->fGPSImgDirection = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSDestBearing", num, den)) exif->fGPSDestBearing = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSDestDistance", num, den)) exif->fGPSDestDistance = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSLatitude", num, den)) exif->fGPSLatitude[0] = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSLongitude", num, den)) exif->fGPSLongitude[0] = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSTimeStamp", num, den)) exif->fGPSTimeStamp[0] = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSDestLatitude", num, den)) exif->fGPSDestLatitude[0] = dng_urational(num, den); if (meta.getExifTagRational("Exif.GPSInfo.GPSDestLongitude", num, den)) exif->fGPSDestLongitude[0] = dng_urational(num, den); // Integer Tags if (meta.getExifTagLong("Exif.Photo.ExposureProgram", val)) exif->fExposureProgram = (uint32)val; if (meta.getExifTagLong("Exif.Photo.MeteringMode", val)) exif->fMeteringMode = (uint32)val; if (meta.getExifTagLong("Exif.Photo.LightSource", val)) exif->fLightSource = (uint32)val; if (meta.getExifTagLong("Exif.Photo.Flash", val)) exif->fFlash = (uint32)val; if (meta.getExifTagLong("Exif.Photo.SensingMethod", val)) exif->fSensingMethod = (uint32)val; if (meta.getExifTagLong("Exif.Photo.FileSource", val)) exif->fFileSource = (uint32)val; if (meta.getExifTagLong("Exif.Photo.SceneType", val)) exif->fSceneType = (uint32)val; if (meta.getExifTagLong("Exif.Photo.CustomRendered", val)) exif->fCustomRendered = (uint32)val; if (meta.getExifTagLong("Exif.Photo.ExposureMode", val)) exif->fExposureMode = (uint32)val; if (meta.getExifTagLong("Exif.Photo.WhiteBalance", val)) exif->fWhiteBalance = (uint32)val; if (meta.getExifTagLong("Exif.Photo.SceneCaptureType", val)) exif->fSceneCaptureType = (uint32)val; if (meta.getExifTagLong("Exif.Photo.GainControl", val)) exif->fGainControl = (uint32)val; if (meta.getExifTagLong("Exif.Photo.Contrast", val)) exif->fContrast = (uint32)val; if (meta.getExifTagLong("Exif.Photo.Saturation", val)) exif->fSaturation = (uint32)val; if (meta.getExifTagLong("Exif.Photo.Sharpness", val)) exif->fSharpness = (uint32)val; if (meta.getExifTagLong("Exif.Photo.SubjectDistanceRange", val)) exif->fSubjectDistanceRange = (uint32)val; if (meta.getExifTagLong("Exif.Photo.FocalLengthIn35mmFilm", val)) exif->fFocalLengthIn35mmFilm = (uint32)val; if (meta.getExifTagLong("Exif.Photo.ComponentsConfiguration", val)) exif->fComponentsConfiguration = (uint32)val; if (meta.getExifTagLong("Exif.Photo.PixelXDimension", val)) exif->fPixelXDimension = (uint32)val; if (meta.getExifTagLong("Exif.Photo.PixelYDimension", val)) exif->fPixelYDimension = (uint32)val; if (meta.getExifTagLong("Exif.Photo.FocalPlaneResolutionUnit", val)) exif->fFocalPlaneResolutionUnit = (uint32)val; if (meta.getExifTagLong("Exif.GPSInfo.GPSVersionID", val)) exif->fGPSVersionID = (uint32)val; if (meta.getExifTagLong("Exif.GPSInfo.GPSAltitudeRef", val)) exif->fGPSAltitudeRef = (uint32)val; if (meta.getExifTagLong("Exif.GPSInfo.GPSDifferential", val)) exif->fGPSDifferential = (uint32)val; } // Markernote backup. QByteArray mkrnts = meta.getExifTagData("Exif.Photo.MakerNote"); if (!mkrnts.isEmpty()) { kDebug( 51000 ) << "DNGWriter: Backup Makernote (" << mkrnts.size() << " bytes)" << endl; dng_memory_allocator memalloc(gDefaultDNGMemoryAllocator); dng_memory_stream stream(memalloc); stream.Put(mkrnts.data(), mkrnts.size()); AutoPtr<dng_memory_block> block(host.Allocate(mkrnts.size())); stream.SetReadPosition(0); stream.Get(block->Buffer(), mkrnts.size()); negative->SetMakerNote(block); negative->SetMakerNoteSafety(true); } if (d->backupOriginalRawFile) { kDebug( 51000 ) << "DNGWriter: Backup Original RAW file (" << inputInfo.size() << " bytes)" << endl; // Compress Raw file data to Zip archive. QTemporaryFile zipFile; if (!zipFile.open()) { kDebug( 51000 ) << "DNGWriter: Cannot open temporary file to write Zip Raw file. Aborted..." << endl; return -1; } KZip zipArchive(zipFile.fileName()); zipArchive.open(QIODevice::WriteOnly); zipArchive.setCompression(KZip::DeflateCompression); zipArchive.addLocalFile(inputFile(), inputFile()); zipArchive.close(); // Load Zip Archive in a byte array QFileInfo zipFileInfo(zipFile.fileName()); QByteArray zipRawFileData; zipRawFileData.resize(zipFileInfo.size()); QDataStream dataStream(&zipFile); dataStream.readRawData(zipRawFileData.data(), zipRawFileData.size()); kDebug( 51000 ) << "DNGWriter: Zipped RAW file size " << zipRawFileData.size() << " bytes" << endl; // Pass byte array to DNG sdk and compute MD5 fingerprint. dng_memory_allocator memalloc(gDefaultDNGMemoryAllocator); dng_memory_stream stream(memalloc); stream.Put(zipRawFileData.data(), zipRawFileData.size()); AutoPtr<dng_memory_block> block(host.Allocate(zipRawFileData.size())); stream.SetReadPosition(0); stream.Get(block->Buffer(), zipRawFileData.size()); dng_md5_printer md5; md5.Process(block->Buffer(), block->LogicalSize()); negative->SetOriginalRawFileData(block); negative->SetOriginalRawFileDigest(md5.Result()); negative->ValidateOriginalRawFileDigest(); zipFile.remove(); } if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: Build DNG Negative" << endl; // Assign Raw image data. negative->SetStage1Image(image); // Compute linearized and range mapped image negative->BuildStage2Image(host); // Compute demosaiced image (used by preview and thumbnail) negative->BuildStage3Image(host); negative->SynchronizeMetadata(); negative->RebuildIPTC(); if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- dng_preview_list previewList; // NOTE: something is wrong with Qt < 4.4.0 to import TIFF data as stream in QImage. #if QT_VERSION >= 0x40400 if (d->previewMode != DNGWriter::NONE) { kDebug( 51000 ) << "DNGWriter: DNG preview image creation" << endl; // Construct a preview image as TIFF format. AutoPtr<dng_image> tiffImage; dng_render tiff_render(host, *negative); tiff_render.SetFinalSpace(dng_space_sRGB::Get()); tiff_render.SetFinalPixelType(ttByte); tiff_render.SetMaximumSize(d->previewMode == MEDIUM ? 1280 : width); tiffImage.Reset(tiff_render.Render()); dng_image_writer tiff_writer; AutoPtr<dng_memory_stream> dms(new dng_memory_stream(gDefaultDNGMemoryAllocator)); tiff_writer.WriteTIFF(host, *dms, *tiffImage.Get(), piRGB, ccUncompressed, negative.Get(), &tiff_render.FinalSpace()); // Write TIFF preview image data to a temp JPEG file std::vector<char> tiff_mem_buffer(dms->Length()); dms->SetReadPosition(0); dms->Get(&tiff_mem_buffer.front(), tiff_mem_buffer.size()); dms.Reset(); QImage pre_image; if (!pre_image.loadFromData((uchar*)&tiff_mem_buffer.front(), tiff_mem_buffer.size(), "TIFF")) { kDebug( 51000 ) << "DNGWriter: Cannot load TIFF preview data in memory. Aborted..." << endl; return -1; } QTemporaryFile previewFile; if (!previewFile.open()) { kDebug( 51000 ) << "DNGWriter: Cannot open temporary file to write JPEG preview. Aborted..." << endl; return -1; } if (!pre_image.save(previewFile.fileName(), "JPEG", 90)) { kDebug( 51000 ) << "DNGWriter: Cannot save file to write JPEG preview. Aborted..." << endl; return -1; } // Load JPEG preview file data in DNG preview container. AutoPtr<dng_jpeg_preview> jpeg_preview; jpeg_preview.Reset(new dng_jpeg_preview); jpeg_preview->fPhotometricInterpretation = piYCbCr; jpeg_preview->fPreviewSize.v = pre_image.height(); jpeg_preview->fPreviewSize.h = pre_image.width(); jpeg_preview->fCompressedData.Reset(host.Allocate(previewFile.size())); QDataStream previewStream( &previewFile ); previewStream.readRawData(jpeg_preview->fCompressedData->Buffer_char(), previewFile.size()); AutoPtr<dng_preview> pp( dynamic_cast<dng_preview*>(jpeg_preview.Release()) ); previewList.Append(pp); previewFile.remove(); } #endif /* QT_VERSION >= 0x40400 */ if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: DNG thumbnail creation" << endl; dng_image_preview thumbnail; dng_render thumbnail_render(host, *negative); thumbnail_render.SetFinalSpace(dng_space_sRGB::Get()); thumbnail_render.SetFinalPixelType(ttByte); thumbnail_render.SetMaximumSize(256); thumbnail.fImage.Reset(thumbnail_render.Render()); if (d->cancel) return -2; // ----------------------------------------------------------------------------------------- kDebug( 51000 ) << "DNGWriter: Creating DNG file " << outputInfo.fileName() << endl; dng_image_writer writer; dng_file_stream filestream(QFile::encodeName(dngFilePath), true); writer.WriteDNG(host, filestream, *negative.Get(), thumbnail, d->jpegLossLessCompression ? ccJPEG : ccUncompressed, &previewList); } catch (const dng_exception &exception) { int ret = exception.ErrorCode(); kDebug( 51000 ) << "DNGWriter: DNG SDK exception code (" << ret << ")" << endl; return ret; } catch (...) { kDebug( 51000 ) << "DNGWriter: DNG SDK exception code unknow" << endl; return dng_error_unknown; } kDebug( 51000 ) << "DNGWriter: DNG conversion complete..." << endl; return dng_error_none; }
void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) { if (!enabledFlag() || !context() || !context()->isValid()) return; // Check that the target has not been deleted if (QQmlData::wasDeleted(object())) return; QString url; quint16 lineNumber; quint16 columnNumber; QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); QV4::Scope scope(ep->v4engine()); QV4::ScopedFunctionObject f(scope, v4function.value()); Q_ASSERT(f); if (f->bindingKeyFlag()) { Q_ASSERT(f->as<QV4::QQmlBindingFunction>()); QQmlSourceLocation loc = static_cast<QV4::QQmlBindingFunction *>(f.getPointer())->d()->bindingLocation; url = loc.sourceFile; lineNumber = loc.line; columnNumber = loc.column; } else { QV4::Function *function = f->asFunctionObject()->function(); Q_ASSERT(function); url = function->sourceFile(); lineNumber = function->compiledFunction->location.line; columnNumber = function->compiledFunction->location.column; } int lineNo = qmlSourceCoordinate(lineNumber); int columnNo = qmlSourceCoordinate(columnNumber); QQmlTrace trace("General Binding Update"); trace.addDetail("URL", url); trace.addDetail("Line", lineNo); trace.addDetail("Column", columnNo); if (!updatingFlag()) { QQmlBindingProfiler prof(ep->profiler, url, lineNo, columnNo); setUpdatingFlag(true); QQmlAbstractExpression::DeleteWatcher watcher(this); if (m_core.propType == qMetaTypeId<QQmlBinding *>()) { int idx = m_core.coreIndex; Q_ASSERT(idx != -1); QQmlBinding *t = this; int status = -1; void *a[] = { &t, 0, &status, &flags }; QMetaObject::metacall(*m_coreObject, QMetaObject::WriteProperty, idx, a); } else { ep->referenceScarceResources(); bool isUndefined = false; QV4::ScopedValue result(scope, QQmlJavaScriptExpression::evaluate(context(), f, &isUndefined)); trace.event("writing binding result"); bool needsErrorLocationData = false; if (!watcher.wasDeleted() && !hasError()) needsErrorLocationData = !QQmlPropertyPrivate::writeBinding(*m_coreObject, m_core, context(), this, result, isUndefined, flags); if (!watcher.wasDeleted()) { if (needsErrorLocationData) delayedError()->setErrorLocation(QUrl(url), lineNumber, columnNumber); if (hasError()) { if (!delayedError()->addError(ep)) ep->warning(this->error(context()->engine)); } else { clearError(); } } ep->dereferenceScarceResources(); } if (!watcher.wasDeleted()) setUpdatingFlag(false); } else { QQmlProperty p = property(); QQmlAbstractBinding::printBindingLoopError(p); } }
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); QStringList args = app.arguments(); args.removeAt(0); std::string profile = "atsc_1080p_24"; bool saveImages = true; bool useFFT = false; // Load arguments foreach (const QString &str, args) { if (str.startsWith("--profile=")) { QString s = str; s.remove(0, QString("--profile=").length()); profile = s.toStdString(); args.removeOne(str); } else if (str == "-h" || str == "--help") { printUsage(argv[0]); return 0; } else if (str == "--no-images") { saveImages = false; args.removeOne(str); } else if (str == "--fft") { useFFT = true; args.removeOne(str); } } if (args.length() < 2) { printUsage(argv[0]); return 1; } std::string fileMain(args.at(0).toStdString()); args.removeFirst(); std::string fileSub = args.at(0).toStdString(); args.removeFirst(); qDebug() << "Unused arguments: " << args; if (argc > 2) { fileMain = argv[1]; fileSub = argv[2]; } else { std::cout << "Usage: " << argv[0] << " <main audio file> <second audio file>" << std::endl; return 0; } std::cout << "Trying to align (2)\n\t" << fileSub << "\nto fit on (1)\n\t" << fileMain << "\n, result will indicate by how much (2) has to be moved." << std::endl << "Profile used: " << profile << std::endl ; if (useFFT) { std::cout << "Will use FFT based correlation." << std::endl; } // Initialize MLT Mlt::Factory::init(NULL); // Load an arbitrary profile Mlt::Profile prof(profile.c_str()); // Load the MLT producers Mlt::Producer prodMain(prof, fileMain.c_str()); if (!prodMain.is_valid()) { std::cout << fileMain << " is invalid." << std::endl; return 2; } Mlt::Producer prodSub(prof, fileSub.c_str()); if (!prodSub.is_valid()) { std::cout << fileSub << " is invalid." << std::endl; return 2; } // Build the audio envelopes for the correlation AudioEnvelope *envelopeMain = new AudioEnvelope(fileMain.c_str(), &prodMain); envelopeMain->loadEnvelope(); envelopeMain->loadStdDev(); envelopeMain->dumpInfo(); AudioEnvelope *envelopeSub = new AudioEnvelope(fileSub.c_str(), &prodSub); envelopeSub->loadEnvelope(); envelopeSub->loadStdDev(); envelopeSub->dumpInfo(); // Calculate the correlation and hereby the audio shift AudioCorrelation corr(envelopeMain); int index = corr.addChild(envelopeSub, useFFT); int shift = corr.getShift(index); std::cout << " Should be shifted by " << shift << " frames: " << fileSub << std::endl << "\trelative to " << fileMain << std::endl << "\tin a " << prodMain.get_fps() << " fps profile (" << profile << ")." << std::endl ; if (saveImages) { QString outImg; outImg = QString("envelope-main-%1.png") .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss")); envelopeMain->drawEnvelope().save(outImg); std::cout << "Saved volume envelope as " << QFileInfo(outImg).absoluteFilePath().toStdString() << std::endl; outImg = QString("envelope-sub-%1.png") .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss")); envelopeSub->drawEnvelope().save(outImg); std::cout << "Saved volume envelope as " << QFileInfo(outImg).absoluteFilePath().toStdString() << std::endl; outImg = QString("correlation-%1.png") .arg(QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss")); corr.info(index)->toImage().save(outImg); std::cout << "Saved correlation image as " << QFileInfo(outImg).absoluteFilePath().toStdString() << std::endl; } // Mlt::Factory::close(); return 0; }
void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) { if (!enabledFlag() || !context() || !context()->isValid()) return; // Check that the target has not been deleted if (QQmlData::wasDeleted(object())) return; int lineNo = qmlSourceCoordinate(m_lineNumber); int columnNo = qmlSourceCoordinate(m_columnNumber); QQmlTrace trace("General Binding Update"); trace.addDetail("URL", m_url); trace.addDetail("Line", lineNo); trace.addDetail("Column", columnNo); if (!updatingFlag()) { QQmlBindingProfiler prof(m_url, lineNo, columnNo, QQmlProfilerService::QmlBinding); setUpdatingFlag(true); QQmlAbstractExpression::DeleteWatcher watcher(this); if (m_core.propType == qMetaTypeId<QQmlBinding *>()) { int idx = m_core.coreIndex; Q_ASSERT(idx != -1); QQmlBinding *t = this; int status = -1; void *a[] = { &t, 0, &status, &flags }; QMetaObject::metacall(*m_coreObject, QMetaObject::WriteProperty, idx, a); } else { QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context()->engine); ep->referenceScarceResources(); bool isUndefined = false; v8::HandleScope handle_scope; v8::Context::Scope scope(ep->v8engine()->context()); v8::Local<v8::Value> result = QQmlJavaScriptExpression::evaluate(context(), v8function, &isUndefined); trace.event("writing binding result"); bool needsErrorLocationData = false; if (!watcher.wasDeleted() && !hasError()) needsErrorLocationData = !QQmlPropertyPrivate::writeBinding(*m_coreObject, m_core, context(), this, result, isUndefined, flags); if (!watcher.wasDeleted()) { if (needsErrorLocationData) delayedError()->setErrorLocation(QUrl(m_url), m_lineNumber, m_columnNumber); if (hasError()) { if (!delayedError()->addError(ep)) ep->warning(this->error(context()->engine)); } else { clearError(); } } ep->dereferenceScarceResources(); } if (!watcher.wasDeleted()) setUpdatingFlag(false); } else { QQmlProperty p = property(); QQmlAbstractBinding::printBindingLoopError(p); } }
static inline int PDHashComparatorCString(const char *key1, const char *key2) { prof(cstring_hashcomps++); return strcmp(key1, key2); }
int VisionController::runFrame(bool lookForBall, bool lookForGoals, bool lookForFieldPoints, bool lookForObstacles) { #ifdef VISION_PROFILER_ON static int frame=0; std::cout << "Profiler started " << ++frame << std::endl; Profiler prof("Vision"); prof.start(); #endif m_data_wrapper = DataWrapper::getInstance(); #if VISION_CONTROLLER_VERBOSITY > 1 debug << "VisionController::runFrame()" << std::endl; debug << "\tBegin" #endif //force blackboard to update from wrapper m_blackboard->update(); #if VISION_CONTROLLER_VERBOSITY > 1 debug << "\tVisionBlackboard updated" << std::endl; #endif #ifdef VISION_PROFILER_ON prof.split("Update"); #endif //! HORIZON GreenHorizonCH::calculateHorizon(); #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tcalculateHorizon done" << std::endl; #endif #ifdef VISION_PROFILER_ON prof.split("Green Horizon"); #endif //! PRE-DETECTION PROCESSING ScanLines::generateScanLines(); #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tgenerateScanLines done" << std::endl; #endif ScanLines::classifyHorizontalScanLines(); #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tclassifyHorizontalScanLines done" << std::endl; #endif ScanLines::classifyVerticalScanLines(); #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tclassifyVerticalScanLines done" << std::endl; #endif #ifdef VISION_PROFILER_ON prof.split("Classify Scanlines"); #endif m_segment_filter.run(); #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tsegment filter done" << std::endl; #endif #ifdef VISION_PROFILER_ON prof.split("Segment Filters"); #endif //! DETECTION MODULES if(lookForGoals) { if(VisionConstants::GOAL_METHOD == HIST) { // histogram method std::vector<Goal> hist_goals = m_goal_detector_hist->run(); m_blackboard->addGoals(hist_goals); } else { //ransac method std::vector<Goal> ransac_goals_edges = m_goal_detector_ransac_edges->run(); //m_goal_detector_ransac_edges->relabel(ransac_goals_edges); m_blackboard->addGoals(ransac_goals_edges); } } else { #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tnot looking for goals" << std::endl; #endif } #ifdef VISION_PROFILER_ON prof.split("Goals"); #endif #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tgoal detection done" << std::endl; #endif if(lookForFieldPoints) { // Edit here to change whether centre circles, lines or corners are found // (note lines cannot be published yet) m_field_point_detector->run(false, true, false); } else { #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tnot looking for lines, corners or the centre circle" << std::endl; #endif } #ifdef VISION_PROFILER_ON prof.split("Field Points"); #endif #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tcentre circle, line and corner detection done" << std::endl; #endif //find balls and publish to BB if(lookForBall) { //m_blackboard->addBalls(m_ball_detector_dave->run()); m_blackboard->addBalls(m_ball_detector_shannon->run()); #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tball detection done" << std::endl; #endif #ifdef VISION_PROFILER_ON prof.split("Ball"); #endif } else { #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tnot looking for ball" << std::endl; #endif } //OBSTACLES std::vector<Obstacle> obstacles; if(lookForObstacles) { obstacles = ObstacleDetectionCH::run(); m_blackboard->addObstacles(obstacles); #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tdetectObstacles done" << std::endl; #endif } else { #if VISION_CONTROLLER_VERBOSITY > 2 debug << "\tnot looking for obstacles" << std::endl; #endif } // ADD IN LABELLING OF GOALS BASED ON KEEPER COLOUR #ifdef VISION_PROFILER_ON prof.split("Obstacles"); #endif // publishing //force blackboard to publish results through wrapper m_blackboard->publish(); #if VISION_CONTROLLER_VERBOSITY > 1 debug << "\tResults published" << std::endl; #endif #ifdef VISION_PROFILER_ON prof.split("Publishing"); #endif //publish debug information as well m_blackboard->debugPublish(); //only debug publish if some verbosity is on #if VISION_CONTROLLER_VERBOSITY > 1 debug << "\tDebugging info published" << std::endl; debug << "\tFinish" << std::endl; #endif #ifdef VISION_PROFILER_ON prof.split("Debug publishing"); prof.stop(); m_profiling_stream << prof << std::endl; #endif return 0; }