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


C++ LayerPtr类代码示例

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


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

示例1: console_filter_selection

int console_filter_selection(ContextPtr env, char *cmd) {
    if(!cmd) return 0;

    LinkList<Filter> &list = env->getFilters();
    LinkList<Filter>::iterator it = std::find_if(list.begin(), list.end(), [&](FilterPtr filter) {
                                                           return filter->getName() == cmd;
                                                       });
    if(it == list.end()) {
        ::error("filter not found: %s", cmd);
        return 0;
    }
    FilterPtr filt = *it;

    ViewPortPtr screen = getSelectedScreen();
    if(!screen) {
        ::error("no screen currently selected");
        return 0;
    }
    LayerPtr lay = getSelectedLayer();
    if(!lay) {
        ::error("no layer selected for effect %s", filt->getName().c_str());
        return 0;
    }

    if(!filt->new_instance()->apply(lay)) {
        ::error("error applying filter %s on layer %s", filt->getName().c_str(), lay->getName().c_str());
        return 0;
    }

    // select automatically the new filter
//  lay->filters.sel(0);
//  ff->sel(true);
    return 1;
}
开发者ID:diorcety,项目名称:FreeJ,代码行数:34,代码来源:console_calls_ctrl.cpp

示例2: Layer

///////////////////////////////////////////////////////////////////////////////
// Called when the "New Layer" button is clicked on the toolbar.  Creates an
// un-doable command that adds a layer to the scene (thereby adding it to this
// control).
// 
void LayersPanel::OnNewLayer( wxCommandEvent& event )
{
    if ( m_Scene )
    {
        LayerPtr layer = new Layer();
        layer->SetOwner( m_Scene );
        m_Scene->Push( new SceneNodeExistenceCommand( Undo::ExistenceActions::Add, m_Scene, layer ) );
        m_Scene->Execute( false ); 
    }
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例3: console_blit_param_selection

int console_blit_param_selection(ContextPtr env, char *cmd) {
    if(!cmd) return 0;

    ViewPortPtr screen = getSelectedScreen();
    if(!screen) {
        ::error("no screen currently selected");
        return 0;
    }
    LayerPtr lay = getSelectedLayer();
    if(!lay) {
        ::error("no layer currently selected");
        return 0;
    }

    BlitInstancePtr b = lay->getCurrentBlit();
    if(!b) {
        ::error("no blit selected on layer %s", lay->getName().c_str());
        return 0;
    }
    // find the values after the first blank space
    char *p;
    for(p = cmd; *p != '\0'; p++)
        if(*p == '=') {
            *p = '\0';
            if(*(p - 1) == ' ')
                *(p - 1) = '\0';
            p++;
            break;
        }

    while(*p == ' ') p++;  // jump all spaces
    if(*p == '\0') return 0;  // no value was given

    LinkList<ParameterInstance> &list = b->getParameters();
    LinkList<ParameterInstance>::iterator it = std::find_if(list.begin(), list.end(), [&](ParameterInstancePtr p) {
                                                              return p->getName() == cmd;
                                                          });
    if(it == list.end()) {
        error("parameter %s not found in blit %s", cmd, b->getName().c_str());
        return 0;
    }

    ParameterInstancePtr param = *it;

    func("parameter %s found in blit %s",  param->getName().c_str(), b->getName().c_str());

    param->parse(p);
    return 1;
}
开发者ID:diorcety,项目名称:FreeJ,代码行数:49,代码来源:console_calls_ctrl.cpp

示例4: TEST

TEST(Layer, WarpCTCLayer) {
  for (auto layerSize : {10, 64}) {
    for (auto batchSize : {1, 10, 32}) {
      for (auto normByTimes : {false, true}) {
        for (auto useGpu : {false, true}) {
#ifndef PADDLE_WITH_CUDA
          if (useGpu) continue;
#endif
          LOG(INFO) << "layerSize=" << layerSize << " batchSize=" << batchSize
                    << " normByTimes = " << normByTimes << " useGpu=" << useGpu;

          FLAGS_use_gpu = useGpu;

          Argument data0;
          initArgument(batchSize, layerSize, useGpu, data0);

          Argument data1;
          data1.resizeAndCopyFrom(data0);

          LayerPtr dataLayer0 =
              createDataLayer("data", batchSize, layerSize, useGpu, data0);
          LayerPtr dataLayer1 =
              createDataLayer("data", batchSize, layerSize, useGpu, data1);

          LayerPtr labelLayer =
              createLabelLayer("label", batchSize, layerSize, useGpu);

          LayerPtr warpctcLayer = createWarpCTCLayer(
              "cost", layerSize, useGpu, normByTimes, dataLayer0, labelLayer);
          LayerPtr ctcLayer = createCTCLayer(
              "cost", layerSize, useGpu, normByTimes, dataLayer1, labelLayer);

          /// Check cost
          LOG(INFO) << "Check cost: "
                    << checkError(*(warpctcLayer->getOutput().value),
                                  *(ctcLayer->getOutput().value))
                    << " different elements.";

          /// Check gradients
          LOG(INFO) << "Check gradients: "
                    << checkError(*(dataLayer0->getOutput().grad),
                                  *(dataLayer1->getOutput().grad))
                    << " different elements";
        }
      }
    }
  }
}
开发者ID:youmingwei,项目名称:Paddle,代码行数:48,代码来源:test_WarpCTCLayer.cpp

示例5: addSublayer

void Layer::addSublayer(const LayerPtr& layer)
{
  if(!isSublayer(layer))
  {
    if(layer->superlayer)
    {
      WOUT("added layer that already had superlayer: "<<layer->description());
    }
    layer->superlayer = this;
    sublayers.push_back(layer);
  }
  else
  {
    WOUT("tried to add layer that was already sublayer: "<<layer->description());
  }
}
开发者ID:jomanto,项目名称:le2,代码行数:16,代码来源:Layer.cpp

示例6: visit

        void Node::visit(const Matrix4& newTransformMatrix, bool parentTransformDirty, const LayerPtr& currentLayer)
        {
            if (parentTransformDirty)
            {
                updateTransform(newTransformMatrix);
            }

            if (transformDirty)
            {
                calculateTransform();
            }

            if (currentLayer)
            {
                for (const NodePtr& child : children)
                {
                    if (child->isVisible())
                    {
                        if (child->isGlobalOrder())
                        {
                            currentLayer->addGlobalNode(child);
                        }

                        child->visit(transform, updateChildrenTransform, currentLayer);
                    }
                }
            }

            updateChildrenTransform = false;
        }
开发者ID:uudens,项目名称:ouzel,代码行数:30,代码来源:Node.cpp

示例7: console_blit_selection

// callbacks used by readline to handle input from console
int console_blit_selection(ContextPtr env, char *cmd) {
    if(!cmd) return 0;
    if(!strlen(cmd)) return 0;

    ViewPortPtr screen = getSelectedScreen();
    if(!screen) {
        ::error("no screen currently selected");
        return 0;
    }
    LayerPtr lay = getSelectedLayer();
    if(!lay) {
        ::error("no layer currently selected");
        return 0;
    }
    lay->set_blit(cmd); // now this takes a string!
    return 1;
}
开发者ID:diorcety,项目名称:FreeJ,代码行数:18,代码来源:console_calls_ctrl.cpp

示例8: doOnePriorBoxTest

// Do one forward pass of priorBox layer and check to see if its output
// matches the given result
void doOnePriorBoxTest(size_t feature_map_width,
                       size_t feature_map_height,
                       size_t image_width,
                       size_t image_height,
                       vector<int> min_size,
                       vector<int> max_size,
                       vector<real> aspect_ratio,
                       vector<real> variance,
                       bool use_gpu,
                       MatrixPtr& result) {
  // Setting up the priorbox layer
  TestConfig configt;
  configt.layerConfig.set_type("priorbox");

  configt.inputDefs.push_back({INPUT_DATA, "featureMap", 1, 0});
  LayerInputConfig* input = configt.layerConfig.add_inputs();
  configt.inputDefs.push_back({INPUT_DATA, "image", 1, 0});
  configt.layerConfig.add_inputs();
  PriorBoxConfig* pb = input->mutable_priorbox_conf();
  for (size_t i = 0; i < min_size.size(); i++) pb->add_min_size(min_size[i]);
  for (size_t i = 0; i < max_size.size(); i++) pb->add_max_size(max_size[i]);
  for (size_t i = 0; i < variance.size(); i++) pb->add_variance(variance[i]);
  for (size_t i = 0; i < aspect_ratio.size(); i++)
    pb->add_aspect_ratio(aspect_ratio[i]);

  // data layer initialize
  std::vector<DataLayerPtr> dataLayers;
  LayerMap layerMap;
  vector<Argument> datas;
  initDataLayer(
      configt, &dataLayers, &datas, &layerMap, "priorbox", 1, false, use_gpu);
  dataLayers[0]->getOutput().setFrameHeight(feature_map_height);
  dataLayers[0]->getOutput().setFrameWidth(feature_map_width);
  dataLayers[1]->getOutput().setFrameHeight(image_height);
  dataLayers[1]->getOutput().setFrameWidth(image_width);

  // test layer initialize
  std::vector<ParameterPtr> parameters;
  LayerPtr priorboxLayer;
  initTestLayer(configt, &layerMap, &parameters, &priorboxLayer);
  priorboxLayer->forward(PASS_GC);
  checkMatrixEqual(priorboxLayer->getOutputValue(), result);
}
开发者ID:Biocodings,项目名称:Paddle,代码行数:45,代码来源:test_PriorBox.cpp

示例9: process

        void Node::process(const LayerPtr& currentLayer)
        {
            if (children.empty())
            {
                if (currentLayer->checkVisibility(std::static_pointer_cast<Node>(shared_from_this())))
                {
                    currentLayer->addToDrawQueue(std::static_pointer_cast<Node>(shared_from_this()));
                }
            }
            else
            {
                std::stable_sort(children.begin(), children.end(), [](const NodePtr& a, const NodePtr& b) {
                    return a->getZ() > b->getZ();
                });

                auto i = children.begin();
                NodePtr node;

                for (; i != children.end(); ++i)
                {
                    node = *i;

                    if (node->getZ() < 0.0f)
                    {
                        if (!node->isGlobalOrder() && node->isVisible() && currentLayer->checkVisibility(node))
                        {
                            currentLayer->addToDrawQueue(node);
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (currentLayer->checkVisibility(std::static_pointer_cast<Node>(shared_from_this())))
                {
                    currentLayer->addToDrawQueue(std::static_pointer_cast<Node>(shared_from_this()));
                }

                for (; i != children.end(); ++i)
                {
                    node = *i;

                    if (!node->isGlobalOrder() && node->isVisible() && currentLayer->checkVisibility(node))
                    {
                        currentLayer->addToDrawQueue(node);
                    }
                }
            }
        }
开发者ID:uudens,项目名称:ouzel,代码行数:51,代码来源:Node.cpp

示例10: BatchUndoCommand

///////////////////////////////////////////////////////////////////////////////
// Called when the "New Layer From Selection" button is clicked on the toolbar.
//
void LayersPanel::OnNewLayerFromSelection( wxCommandEvent& dummyEvt )
{
    if ( m_Scene )
    {
        if(IsSelectionValid() == false)
        {
            return;
        }

        BatchUndoCommandPtr batch = new BatchUndoCommand ();
        LayerPtr layer = new Layer();
        layer->SetOwner( m_Scene );
        layer->Initialize();

        // Generate a name for this layer
        GenerateLayerName(layer);

        batch->Push( new SceneNodeExistenceCommand( ExistenceActions::Add, m_Scene, layer ) );

        // Step 2: add all the selected items to the layer
        const OS_ObjectDumbPtr& selection = m_Scene->GetSelection().GetItems();
        OS_ObjectDumbPtr::Iterator itr = selection.Begin();
        OS_ObjectDumbPtr::Iterator end = selection.End();
        for ( ; itr != end; ++itr )
        {
            //If the element is a supported type
            if( *itr )
            {
                SceneNode* node = Reflect::SafeCast< SceneNode >( *itr );
                if ( node )
                {
                    batch->Push( new DependencyCommand( DependencyCommand::Connect, layer, node ) );
                }
            }
        }

        m_Scene->Push( batch );
        m_Scene->Execute( false );
    }
}
开发者ID:justinliew,项目名称:Helium,代码行数:43,代码来源:LayersPanel.cpp

示例11: apply

bool FreeframeInstance::apply(LayerPtr lay) {
    if(!FilterInstance::apply(lay)) {
        return false;
    }
    auto freeframe = DynamicPointerCast<Freeframe>(proto);
    auto &geo = lay->getGeometry();
    VideoInfoStruct vidinfo;
    vidinfo.frameWidth = geo.w;
    vidinfo.frameHeight = geo.h;
    vidinfo.orientation = 1;
    vidinfo.bitDepth = FF_CAP_32BITVIDEO;
    core = freeframe->plugmain(FF_INSTANTIATE, &vidinfo, 0).ivalue;
    return core != FF_FAIL;
}
开发者ID:K0F,项目名称:FreeJ,代码行数:14,代码来源:freeframe_instance.cpp

示例12: draw

        void Node::draw(const LayerPtr& currentLayer)
        {
            if (transformDirty)
            {
                calculateTransform();
            }

            if (currentLayer)
            {
                if (currentLayer->getCamera())
                {
                    graphics::Color drawColor(color.r, color.g, color.b, static_cast<uint8_t>(color.a * opacity));

                    for (const DrawablePtr& drawable : drawables)
                    {
                        if (drawable->isVisible())
                        {
                            drawable->draw(currentLayer->getCamera()->getViewProjection(), transform, drawColor);
                        }
                    }
                }
            }
        }
开发者ID:uudens,项目名称:ouzel,代码行数:23,代码来源:Node.cpp

示例13: removeSublayer

void Layer::removeSublayer(const LayerPtr& layer)
{
  auto pos = std::find(sublayers.begin(), sublayers.end(), layer);
  if(pos != sublayers.end())
  {
    LayerPtr sublayer = *pos;
    sublayer->superlayer = NULL;
    sublayers.erase(pos);
  }
  else
  {
    WOUT("tried to remove layer that wasn't sublayer: "<<layer->description());
  }
}
开发者ID:lobotony,项目名称:le2,代码行数:14,代码来源:Layer.cpp

示例14: debug

/**
 * \brief Add an image
 *
 * Adding an image to the stack means that we have to find the transform
 * is needed to make the image congruent to the base image
 */
void	Stack::add(ImagePtr image) {
	debug(LOG_DEBUG, DEBUG_LOG, 0,
		"adding %s-sized image to stack (already %d images)",
		image->size().toString().c_str(), size());

	// create a new layer
	LayerPtr	newlayer = LayerPtr(new Layer(image));

	// get adapters for the two images to compare
	StackingAdapter	*baseadapter = StackingAdapter::get(_base);
	StackingAdapterPtr	baseadapterptr(baseadapter);
	StackingAdapter	*imageadapter = StackingAdapter::get(image);
	StackingAdapterPtr	imageadapterptr(imageadapter);

	// use a transform analyzer to find the transform, add the transform
	// to the layer
	transform::TransformAnalyzer	ta(*baseadapter, 2048, 2048);
	newlayer->transform(ta(*imageadapter));

	// add the layer to the stack
	debug(LOG_DEBUG, DEBUG_LOG, 0, "adding layer %d: %s", size(),
		newlayer->toString().c_str());
	push_back(newlayer);
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:30,代码来源:Stack.cpp

示例15: doOneConvtTest

// Do one forward pass of convTrans layer and check to see if its output
// matches the given result
void doOneConvtTest(size_t imgSize,
                    size_t output_x,
                    size_t stride,
                    size_t padding,
                    size_t filter_size,
                    MatrixPtr& result) {
  TestConfig configt;
  configt.biasSize = 1;
  configt.layerConfig.set_type("exconvt");
  configt.layerConfig.set_num_filters(1);
  configt.layerConfig.set_partial_sum(1);
  configt.layerConfig.set_shared_biases(true);

  configt.inputDefs.push_back(
      {INPUT_DATA, "layer_0", output_x * output_x, filter_size * filter_size});
  LayerInputConfig* input = configt.layerConfig.add_inputs();
  ConvConfig* conv = input->mutable_conv_conf();
  conv->set_filter_size(filter_size);
  conv->set_filter_size_y(filter_size);
  conv->set_channels(1);
  conv->set_padding(padding);
  conv->set_padding_y(padding);
  conv->set_stride(stride);
  conv->set_stride_y(stride);
  conv->set_groups(1);
  conv->set_filter_channels(1);
  conv->set_img_size(imgSize);
  conv->set_output_x(output_x);

  configt.layerConfig.set_size(conv->img_size() * conv->img_size() *
                               configt.layerConfig.num_filters());
  configt.layerConfig.set_name("convTrans");

  std::vector<DataLayerPtr> dataLayers;
  LayerMap layerMap;
  vector<Argument> datas;
  initDataLayer(
      configt, &dataLayers, &datas, &layerMap, "convTrans", 1, false, false);
  dataLayers[0]->getOutputValue()->zeroMem();
  dataLayers[0]->getOutputValue()->add(1.0);

  // test layer initialize
  std::vector<ParameterPtr> parameters;
  LayerPtr convtLayer;
  initTestLayer(configt, &layerMap, &parameters, &convtLayer);
  convtLayer->getBiasParameter()->zeroMem();
  convtLayer->getParameters()[0]->zeroMem();
  convtLayer->getParameters()[0]->getBuf(PARAMETER_VALUE)->add(1.0);
  convtLayer->forward(PASS_GC);

  checkMatrixEqual(convtLayer->getOutputValue(), result);
}
开发者ID:Biocodings,项目名称:Paddle,代码行数:54,代码来源:test_ConvTrans.cpp


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