本文整理汇总了C++中DataProvider::sendOutputData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataProvider::sendOutputData方法的具体用法?C++ DataProvider::sendOutputData怎么用?C++ DataProvider::sendOutputData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataProvider
的用法示例。
在下文中一共展示了DataProvider::sendOutputData方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void ReadDirectory::execute(DataProvider& provider)
{
if (m_files.size() == 0)
throw OperatorError(*this, "Directory is empty.");
Data* data = 0;
std::size_t index = m_currentIndex;
do
{
boost::filesystem::path file(m_files[index]);
index = (index + 1) % m_files.size();
std::string ext = file.extension().string();
std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
if (ext == ".png" || ext == ".jpg" || ext == ".jpeg")
{
data = new cvsupport::Image(file.string());
}
}
while (data == 0 && index != m_currentIndex);
m_currentIndex = index;
if (data == 0)
throw OperatorError(*this, "Found no usable file in selected directory.");
DataContainer container(data);
Id2DataPair outputDataMapper(OUTPUT, container);
provider.sendOutputData(outputDataMapper);
}
示例2: execute
void CameraBuffer::execute(DataProvider& provider)
{
// get the input data
Id2DataPair inputMapper(INPUT);
provider.receiveInputData(inputMapper);
// try to get a free buffer
Data* buffer = 0;
try
{
buffer = m_buffers(0);
}
catch(Timeout&)
{
}
if(buffer)
{
// there was a free buffer
DataContainer bufferContainer(buffer);
// remember it in the recycling access
m_buffers.add(bufferContainer);
Id2DataPair outputMapper(OUTPUT, inputMapper.data());
Id2DataPair bufferMapper(BUFFER, bufferContainer);
Id2DataPair idMapper(INDEX, DataContainer(new UInt32(m_id)));
// send it to the output (together with the input image and the current index)
provider.sendOutputData(outputMapper && bufferMapper && idMapper);
}
// increase the index
++m_id;
}
示例3: execute
void Split::execute(DataProvider& provider)
{
if (m_storedItems.size() == 0)
{
RecycleAccess recycle;
{
Id2DataPair input(INPUT);
provider.receiveInputData(input);
recycle.add(input.data());
}
Data* data = recycle.get();
List* list = data_cast<List>(data);
if (list == 0)
throw InputError(INPUT, *this, "Input data must be a 'List' object.");
for (std::vector<Data*>::iterator iter = list->content().begin();
iter != list->content().end(); ++iter)
{
m_storedItems.push_back(DataContainer(*iter));
}
uint64_t size = list->content().size();
list->content().clear();
delete list;
DataContainer outNumItems(new UInt64(size));
Id2DataPair dataMapper(OUTPUT_NUM_ITEMS, outNumItems);
provider.sendOutputData(dataMapper);
}
if (m_storedItems.size() != 0)
{
DataContainer outData = m_storedItems.front();
Id2DataPair dataMapper(OUTPUT_DATA, outData);
m_storedItems.pop_front();
provider.sendOutputData(dataMapper);
}
}
示例4: execute
void ParameterOperator::execute(DataProvider& provider)
{
Id2DataPair input1(INPUT_1);
Id2DataPair input2(INPUT_2);
provider.receiveInputData(input1 && input2);
// execute...
Id2DataPair output1(OUTPUT_1, input1.data());
Id2DataPair output2(OUTPUT_2, input2.data());
provider.sendOutputData(output1 && output2);
}
示例5: execute
void ReadGpio::execute(DataProvider& provider)
{
int value = impl::GPIORead(static_cast<int>(m_gpio));
if (-1 == value)
{
throw OperatorError(*this,
(boost::format("Failed to read from GPIO %1%.") % m_gpio).str());
}
DataContainer data(new Bool(value));
Id2DataPair output(OUTPUT, data);
provider.sendOutputData(output);
}
示例6: execute
void Merge::execute(DataProvider& provider)
{
if (m_list == 0)
{
Id2DataPair dataMapper(INPUT_NUM_ITEMS);
provider.receiveInputData(dataMapper);
ReadAccess access(dataMapper.data());
try
{
m_numItems = toInt(access.get());
}
catch (BadCast&)
{
throw InputError(INPUT_NUM_ITEMS, *this, "Number of items must be an integer.");
}
m_list = new List();
}
if (m_list->content().size() < m_numItems)
{
RecycleAccess recycler;
{
Id2DataPair dataMapper(INPUT_DATA);
provider.receiveInputData(dataMapper);
recycler.add(dataMapper.data());
}
Data* data = recycler.get();
m_list->content().push_back(data);
}
if (m_list->content().size() == m_numItems)
{
DataContainer out(m_list);
m_list = 0;
m_numItems = 0;
Id2DataPair dataMapper(OUTPUT, out);
provider.sendOutputData(dataMapper);
}
}
示例7: execute
void ConstData::execute(DataProvider& provider)
{
if (! valuePtr())
throw InternalError("Value has not been set");
DataContainer data;
if (m_allocateData)
{
data = DataContainer(valuePtr()->clone());
}
else
{
Data* dataPtr = 0;
if (m_recycleAccess.empty())
{
// if this is the first time the operator executes the value must
// be cloned
dataPtr = valuePtr()->clone();
}
else
{
// otherwise the value in the recycler can be reused
dataPtr = m_recycleAccess.get();
}
if (dataPtr != valuePtr())
{
// if the value was changed by the user since the last execution
// update it
delete dataPtr;
dataPtr = valuePtr()->clone();
}
// send and remember for the next execution
data = DataContainer(dataPtr);
m_recycleAccess.add(data);
}
Id2DataPair outputDataMapper(OUTPUT, data);
provider.sendOutputData( outputDataMapper);
}
示例8: execute
void TestOperator::execute(DataProvider& provider)
{
if(m_throwException)
{
throw InternalError("Funny exception.");
}
Id2DataPair input1(INPUT_1);
Id2DataPair input2(INPUT_2);
provider.receiveInputData(input1 && input2);
// execute...
m_numExecutes++;
boost::this_thread::sleep_for(boost::chrono::milliseconds(m_sleepTime));
Id2DataPair output1(OUTPUT_1, input1.data());
Id2DataPair output2(OUTPUT_2, input2.data());
provider.sendOutputData(output1 && output2);
}
示例9: execute
void Flicker::execute(DataProvider& provider)
{
Id2DataPair inputDataMapper(INPUT);
provider.receiveInputData(inputDataMapper);
DataContainer container = inputDataMapper.data();
WriteAccess access(container);
runtime::Image& image = access.get<runtime::Image>();
switch(image.depth())
{
case 1:
applyFlicker<uint8_t>(m_amount, image);
break;
case 2:
applyFlicker<uint16_t>(m_amount, image);
break;
default:
throw WrongInputType(INPUT, *this);
}
Id2DataPair outputDataMapper(OUTPUT, container);
provider.sendOutputData( outputDataMapper);
}
示例10: execute
void ConvertPixelType::execute(DataProvider& provider)
{
if (m_dataFlow == MANUAL)
{
Id2DataPair srcMapper(SOURCE);
Id2DataPair destMapper(DESTINATION);
provider.receiveInputData(srcMapper && destMapper);
if(srcMapper.data() == destMapper.data())
throw InputError(DESTINATION, *this, "Destination image must not be the same image as the source image.");
ReadAccess src(srcMapper.data());
WriteAccess dest(destMapper.data());
const runtime::Image& srcImage = src.get<runtime::Image>();
runtime::Image& destImage = dest.get<runtime::Image>();
runtime::Image::PixelType pixelType = runtime::Image::PixelType((unsigned int)(m_pixelType));
unsigned int destImageSize = srcImage.width() * srcImage.height() * getDestPixelSize(pixelType);
unsigned int destImageStride = srcImage.width() * getDestPixelSize(pixelType);
if(destImage.bufferSize() < destImageSize)
throw InputError(DESTINATION, *this, "Destination image is too small.");
destImage.initializeImage(srcImage.width(), srcImage.height(), destImageStride, destImage.buffer(), pixelType);
if((srcImage.pixelType() == runtime::Image::RGB_24 || srcImage.pixelType() == runtime::Image::BGR_24)
&& (pixelType == runtime::Image::BAYERBG_8 || pixelType == runtime::Image::BAYERGB_8))
{
// this case is not handled by OpenCV
rgbToBayer(srcImage, destImage);
}
else
{
// use OpenCV for conversion
openCvConversion(srcImage, destImage);
}
Id2DataPair outputMapper(OUTPUT, destMapper.data());
provider.sendOutputData( outputMapper);
}
else // allocate destination data on the fly
{
Id2DataPair srcMapper(SOURCE);
provider.receiveInputData(srcMapper);
ReadAccess src(srcMapper.data());
const runtime::Image& srcImage = src.get<runtime::Image>();
runtime::Image::PixelType pixelType = runtime::Image::PixelType((unsigned int)(m_pixelType));
runtime::Image* destImage = new cvsupport::Image(srcImage.width(), srcImage.height(), pixelType);
DataContainer destContainer(destImage);
if((srcImage.pixelType() == runtime::Image::RGB_24 || srcImage.pixelType() == runtime::Image::BGR_24)
&& (pixelType == runtime::Image::BAYERBG_8 || pixelType == runtime::Image::BAYERGB_8))
{
// this case is not handled by OpenCV
rgbToBayer(srcImage, *destImage);
}
else
{
// use OpenCV for conversion
openCvConversion(srcImage, *destImage);
}
Id2DataPair outputMapper(OUTPUT, destContainer);
provider.sendOutputData( outputMapper);
}
}