当前位置: 首页>>代码示例>>C++>>正文


C++ QScopedPointer::init方法代码示例

本文整理汇总了C++中QScopedPointer::init方法的典型用法代码示例。如果您正苦于以下问题:C++ QScopedPointer::init方法的具体用法?C++ QScopedPointer::init怎么用?C++ QScopedPointer::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QScopedPointer的用法示例。


在下文中一共展示了QScopedPointer::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: compare


//.........这里部分代码省略.........
        {
            needEnrollRows = true;
        }

        // At this point, we have decided how we will structure the comparison (either in transpose mode, or not), 
        // and have the column gallery enrolled, and have decided whether or not we need to enroll the row gallery.
        // From this point, we will build a single algorithm that (optionally) does enrollment, then does comparisons
        // and output, optionally using ProcessWrapper to do the enrollment and comparison in separate processes.
        //
        // There are two main components to this algorithm. The first is the (optional) enrollment and then the
        // comparison step (built from a GalleryCompare transform), and the second is the sequential matrix output and
        // progress counting step.
        // After the base algorithm is built, the whole thing will be run in a stream, so that I/O can be handled sequentially.

        // The actual comparison step is done by a GalleryCompare transform, which has a Distance, and a gallery as data.
        // Incoming templates are compared against the templates in the gallery, and the output is the resulting score
        // vector.
        QString compareRegionDesc = "Pipe([GalleryCompare("+Globals->algorithm + "," + colEnrolledGallery.flat() + ")])";


        QScopedPointer<Transform> compareRegion;
        // If we need to enroll the row set, we add the current algorithm's enrollment transform before the
        // GalleryCompare in a pipe.
        if (needEnrollRows)
        {
            if (!multiProcess)
            {
                compareRegionDesc = compareRegionDesc;
                compareRegion.reset(Transform::make(compareRegionDesc,NULL));
                CompositeTransform * downcast = dynamic_cast<CompositeTransform *> (compareRegion.data());
                if (downcast == NULL)
                    qFatal("Pipe downcast failed in compare");

                downcast->transforms.prepend(this->transform.data());
                downcast->init();
            }
            else
            {
                compareRegionDesc = "ProcessWrapper(" + this->transformString + "+" + compareRegionDesc + ")";
                compareRegion.reset(Transform::make(compareRegionDesc, NULL));
            }
        }
        else {
            if (multiProcess)
                compareRegionDesc = "ProcessWrapper(" + compareRegionDesc + ")";
            compareRegion.reset(Transform::make(compareRegionDesc,NULL));
        }

        // At this point, compareRegion is a transform, which optionally does enrollment, then compares the row
        // set against the column set. If in multi-process mode, the enrollment and comparison are wrapped in a 
        // ProcessWrapper transform, and will be transparently run in multiple processes.
        compareRegion->init();


        // We also need to add Output and progress counting to the algorithm we are building, so we will assign them to
        // two stages of a pipe.
        QString joinDesc = "Pipe()";
        QScopedPointer<Transform> join(Transform::make(joinDesc, NULL));

        // The output transform takes the metadata memGalleries we set up previously as input, along with the
        // output specification we were passed. Gallery metadata is necessary for some Outputs to function correctly.
        QString outputString = output.flat().isEmpty() ? "Empty" : output.flat();
        QString outputRegionDesc = "Output("+ outputString +"," + targetGallery.flat() +"," + queryGallery.flat() + ","+ QString::number(transposeMode ? 1 : 0) + ")";
        // The ProgressCounter transform will simply provide a display about the number of rows completed.
        outputRegionDesc += "+ProgressCounter("+QString::number(rowSize)+")+Discard";
        QScopedPointer<Transform> outputTform(Transform::make(outputRegionDesc, NULL));

        // Assign the comparison transform we previously built, and the output transform  we just built to
        // two stages of a pipe.
        CompositeTransform * downcast = dynamic_cast<CompositeTransform *> (join.data());
        downcast->transforms.append(compareRegion.data());
        downcast->transforms.append(outputTform.data());

        // With this, we have set up a transform which (optionally) enrolls templates, compares them
        // against a gallery, and outputs them.
        join->init();

        // Now, we will give that base transform to a stream, which will incrementally read the row gallery
        // and pass the transforms it reads through the base algorithm.
        QString streamDesc = "Stream(readMode=StreamGallery)";
        QScopedPointer<Transform> streamBase(Transform::make(streamDesc, NULL));
        WrapperTransform * streamWrapper = dynamic_cast<WrapperTransform *> (streamBase.data());
        streamWrapper->transform = join.data();

        // The transform we will use is now complete.
        streamWrapper->init();

        // We set up a template containing the rowGallery we want to compare. 
        TemplateList rowGalleryTemplate;
        rowGalleryTemplate.append(Template(rowGallery));
        TemplateList outputGallery;

        // Set up progress counting variables
        Globals->currentStep = 0;
        Globals->totalSteps = rowSize;
        Globals->startTime.start();

        // Do the actual comparisons
        streamWrapper->projectUpdate(rowGalleryTemplate, outputGallery);
    }
开发者ID:ShivaniBhardwaj,项目名称:openbr,代码行数:101,代码来源:core.cpp


注:本文中的QScopedPointer::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。