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


C++ ALValue::getType方法代码示例

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


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

示例1: testRemote

/**
 * saveImageRemote : test remote image
 * @param pName path of the file
 */
void vision::testRemote(){

  //Now you can get the pointer to the video structure.
  ALValue results;
  results.arraySetSize(7);

  try
  {
    results = ( camera->call<ALValue>( "getImageRemote", name ) );
  }catch( ALError& e)
  {
    log->error( "vision", "could not call the getImageRemote method of the NaoCam module" );
  }

  if (results.getType()!= ALValue::TypeArray) return;

  const char* dataPointerIn =  static_cast<const char*>(results[6].GetBinary());
  int size = results[6].getSize();

  //You can get some informations of the image.
  int width = (int) results[0];
  int height = (int) results[1];
  int nbLayers = (int) results[2];
  int colorSpace = (int) results[3];
  long long timeStamp = ((long long)(int)results[4])*1000000LL + ((long long)(int)results[5]);

  // now you create an openCV image and you save it in a file.
  IplImage* image = cvCreateImage( cvSize( width, height ), 8, nbLayers );

//  image->imageData = ( char* ) imageIn->getFrame();
  image->imageData = ( char* ) dataPointerIn;

  std::string pName = "aaa";

  //const char* imageName = ( pName + DecToString(results[4]) + ".jpg").c_str();
  const char* imageName = ( pName + "test" + ".jpg").c_str();

printf("imageName %s\n", imageName);
  cvSaveImage( imageName, image );
printf("image saved\n");

try
{
  results = ( camera->call<ALValue>( "releaseImage", name ) );
}catch( ALError& e)
{
  log->error( "vision", "could not call the releaseImage method of the NaoCam module" );
}

printf("image memory released\n");

//  cvReleaseImage( &image );
  cvReleaseImageHeader(&image);
printf("image released\n");
printf("testRemote finished\n");
}
开发者ID:alon,项目名称:burst,代码行数:60,代码来源:vision.cpp

示例2: fetchImage

struct timespec KImageExtractor::fetchImage(IplImage *img)
{
    struct timespec rt;//Timestamp
    cout<<"KImageExtractor::fetchimage():"<<endl;
    if (doneSubscribe==false)
    {
        cout<<"KImageExtractor: Warning! fetchImage()  called although GVM Subscription has failed!"<<endl;
        rt.tv_sec=0;
        rt.tv_nsec=0;
        return rt;
    }

#ifdef REMOTE_ON
    //		cout << "Remote method on" << endl;
    //		sleep(1);
    ALValue results;
#ifdef RAW

    results = (c->call<ALValue> ("getDirectRawImageRemote", GVM_name));
#else
    results = (c->call<ALValue> ("getImageRemote", GVM_name));
#endif
    if (results.getType() != ALValue::TypeArray && results.getSize() != 7)
    {
        throw ALError("KImageExtractor", "saveImageRemote", "Invalid image returned.");
    }
    //const int size = results[6].getSize();
    // You can get some image information that you may find useful.
    //	const int width = (int) results[0];
    //	const int height = (int) results[1];
    //	const int nbLayers = (int) results[2];
    //	const int colorSpace = (int) results[3];
    //const long long timeStamp = ((long long) (int) results[4]) * 1000000LL + ((long long) (int) results[5]);
    //	const int seconds = (int) (timeStamp / 1000000LL);
    // Set the buffer we received to our IplImage header.
    //fIplImageHeader->imageData = (char*) (results[6].GetBinary());
    //cout << "Size" << size << endl;



    int width = (int) results[0];
    int height = (int) results[1];
    int nChannels = (int) results[2];
    int colorSpace = (int) results[3];

    int size =width*height*nChannels;

    //Fetch TimeStamp;
    rt.tv_sec=(time_t)((int) results[4]);
    rt.tv_nsec=(int)  results[5]*1000L;

    //Change of image data size
    assert(img!=NULL);
    //cout<<img->imageSize<<" "<<size<<endl;
    if (img->imageSize!=size )
    {
        //cout<<img->width<<" "<<img->height<<endl;
        cout<<"KImageExtractor::fetchImage():allocating new imagedata"<<endl;
        //cout<<"Delete old"<<endl;
        //delete img->imageData;
        //img->imageData=NULL;
        cout<<"cvInitImage"<<endl;
        cvInitImageHeader(img,  cvSize(width,height),IPL_DEPTH_8U, nChannels);
        //img->imageData=NULL;
        cout<<" Done"<<endl;
        //img->imageData=(char*)malloc(img->imageSize);
    }


    if (img->imageData != NULL)
    {
        //free( fIplImageHeader->imageData)
        memcpy(img->imageData, (char*) (results[6].GetBinary()), results[6].getSize() * sizeof(unsigned char));
    }
    else
    {
        img->imageData = new char[img->imageSize];
        memcpy(img->imageData, (char*) (results[6].GetBinary()), results[6].getSize() * sizeof(char));
    }
#else
    //cout << "Remote method off" << endl;
    //sleep(1);
    ALImage* imageIn = NULL;
    // Now you can get the pointer to the video structure.
#ifdef RAW
    imageIn = (ALImage*) (c->call<int> ("getDirectRawImage", GVM_name));
#else
    imageIn = (ALImage*) (c->call<int> ("getImageLocal", GVM_name));
#endif
    if (!imageIn)
    {
        throw ALError("KImageExtractor", "saveImageLocal", "Invalid image returned.");
    }
    //fLogProxy->info(getName(), imageIn->toString());
    // You can get some image information that you may find useful.
    int width = imageIn->fWidth;
    int height = imageIn->fHeight;
    const int nChannels = imageIn->fNbLayers;
    //		const int colorSpace = imageIn->fColorSpace;
    const long long timeStamp = imageIn->fTimeStamp;
//.........这里部分代码省略.........
开发者ID:cbm,项目名称:KArch,代码行数:101,代码来源:KImageExtractor.cpp


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