GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo)
{
    cv::gpu::DeviceInfo devInfo = GetParam();
    cv::gpu::setDevice(devInfo.deviceID());

    cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
    ASSERT_FALSE(img_l_host.empty());

    cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
    ASSERT_FALSE(img_r_host.empty());

    cv::gpu::StereoConstantSpaceBP csbp(128);
    cv::gpu::GpuMat img_l(img_l_host);
    cv::gpu::GpuMat img_r(img_r_host);
    cv::gpu::GpuMat dst;

    csbp(img_l, img_r, dst);

    declare.time(10.0);

    TEST_CYCLE()
    {
        csbp(img_l, img_r, dst);
    }
}
Beispiel #2
0
//Image readImage reads the same thing to every batch
//This call is here since this is the entry point called from allocate
//Movie overwrites this function to define how it wants to load into batches
int Movie::retrieveData(double timef, double dt)
{
   int status = PV_SUCCESS;
   bool init = false;
   for(int b = 0; b < parent->getNBatch(); b++){
      if(parent->icCommunicator()->commRank() == 0){
         if(framePath[b]!= NULL) free(framePath[b]);
         if(!initFlag){
            framePath[b] = strdup(getNextFileName(startFrameIndex[b]+1, b));
            init = true;
         }
         else{
            framePath[b] = strdup(getNextFileName(skipFrameIndex[b], b));
         }
         std::cout << "Reading frame " << framePath[b] << " into batch " << b << " at time " << timef << "\n";
         status = readImage(framePath[b], b, offsets[0], offsets[1], offsetAnchor);
      }
      else{
         status = readImage(NULL, b, offsets[0], offsets[1], offsetAnchor);
      }

      if( status != PV_SUCCESS ) {
         fprintf(stderr, "Movie %s: Error reading file \"%s\"\n", name, framePath[b]);
         abort();
      }
   }
   if(init){
      initFlag = true;
   }
   return status;
}
PERF_TEST_P(DevInfo, StereoBeliefPropagation, testing::ValuesIn(devices()))
{
    DeviceInfo devInfo = GetParam();

    setDevice(devInfo.deviceID());

    Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
    Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);

    ASSERT_FALSE(img_l_host.empty());
    ASSERT_FALSE(img_r_host.empty());

    GpuMat img_l(img_l_host);
    GpuMat img_r(img_r_host);

    GpuMat dst;

    StereoBeliefPropagation bp(128);

    declare.time(10.0);

    SIMPLE_TEST_CYCLE()
    {
        bp(img_l, img_r, dst);
    }

    Mat dst_host(dst);
    
    SANITY_CHECK(dst_host);
}
PERF_TEST_P(DevInfo, StereoConstantSpaceBP, testing::ValuesIn(devices()))
{
    DeviceInfo devInfo = GetParam();

    setDevice(devInfo.deviceID());

    Mat img_l_host = readImage("gpu/perf/aloe.jpg", CV_LOAD_IMAGE_GRAYSCALE);
    Mat img_r_host = readImage("gpu/perf/aloeR.jpg", CV_LOAD_IMAGE_GRAYSCALE);

    ASSERT_FALSE(img_l_host.empty());
    ASSERT_FALSE(img_r_host.empty());

    GpuMat img_l(img_l_host);
    GpuMat img_r(img_r_host);

    GpuMat dst;

    StereoConstantSpaceBP bp(128);

    declare.time(10.0);

    SIMPLE_TEST_CYCLE()
    {
        bp(img_l, img_r, dst);
    }

    Mat dst_host(dst);
    
    SANITY_CHECK(dst_host);
}
GPU_PERF_TEST_1(StereoBeliefPropagation, cv::gpu::DeviceInfo)
{
    cv::gpu::DeviceInfo devInfo = GetParam();
    cv::gpu::setDevice(devInfo.deviceID());

    cv::Mat img_l_host = readImage("gpu/stereobp/aloe-L.png");
    ASSERT_FALSE(img_l_host.empty());

    cv::Mat img_r_host = readImage("gpu/stereobp/aloe-R.png");
    ASSERT_FALSE(img_r_host.empty());

    cv::gpu::StereoBeliefPropagation bp(64);
    cv::gpu::GpuMat img_l(img_l_host);
    cv::gpu::GpuMat img_r(img_r_host);
    cv::gpu::GpuMat dst;

    bp(img_l, img_r, dst);

    declare.time(10.0);

    TEST_CYCLE()
    {
        bp(img_l, img_r, dst);
    }
}
GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo)
{
    cv::gpu::DeviceInfo devInfo = GetParam();
    cv::gpu::setDevice(devInfo.deviceID());

    cv::Mat img_l_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
    ASSERT_FALSE(img_l_host.empty());

    cv::Mat img_r_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
    ASSERT_FALSE(img_r_host.empty());

    cv::gpu::StereoBM_GPU bm(0, 256);
    cv::gpu::GpuMat img_l(img_l_host);
    cv::gpu::GpuMat img_r(img_r_host);
    cv::gpu::GpuMat dst;

    bm(img_l, img_r, dst);

    declare.time(5.0);

    TEST_CYCLE()
    {
        bm(img_l, img_r, dst);
    }
}
Beispiel #7
0
int main(int argc,char *argv){
	FILE *fp;
	char input[100];
	scanf("%s",input);
	char name[strlen(input)+1];
	snprintf(name,sizeof(name),"%s",input);
	fp=fopen(name,"rb");
	if(fp==NULL){
		printf("file not found\n");
		return 0;
	}
	head *h=readHeader(fp);
	pinfo info;
	info.padding=0;
	info.padding=calcPadding(h);



	pi **a=readImage(h->width,h->height,h->bfoffset,fp,&info);
	//The image is stored bottom to top and left to right


/*	int swidth,sheight,ewidth,eheight;
	printf("Enter the starting width and height: ");
	scanf("%d %d",&swidth,&sheight);
	printf("Enter the width and height to be cropped: ");
	scanf("%d %d",&ewidth,&eheight);
	crop(h,a,swidth,h->height-sheight,swidth+ewidth,h->height-sheight-eheight);
	writeImage(fp,a,h,h->width,h->height,&info);
*/

//	int swidth=598,sheight=375,ewidth=568,eheight=73;
//	int swidth=620,sheight=372,ewidth=525,eheight=68;//scan
//	int swidth=867,sheight=585,ewidth=775,eheight=75;//daa2,daa3
//	int swidth=895,sheight=585,ewidth=775,eheight=75;//daa5
	int swidth=895,sheight=585,ewidth=785,eheight=80;//daa6
	a=crop(h,a,swidth,h->height-sheight,swidth+ewidth,h->height-sheight-eheight);
	head *newH=changeHeader(h,ewidth,eheight);
//	toJpeg("usn.jpeg",newH,a);
	writeImage(a,newH,&info,"usn.bmp");
	fp=fopen("usn.bmp","rb");
	if(fp==NULL){
		printf("file not found\n");
		return 0;
	}
	
	h=readHeader(fp);
	info.padding=calcPadding(h);
	
	a=readImage(h->width,h->height,h->bfoffset,fp,&info);
	slice(h,a,&info,10);

	
	fclose(fp);


	return 0;
}
Beispiel #8
0
    virtual void SetUp() 
    {
        devInfo = GetParam();

        cv::gpu::setDevice(devInfo.deviceID());
        
        img_l = readImage("stereobm/aloe-L.png", CV_LOAD_IMAGE_GRAYSCALE);
        img_r = readImage("stereobm/aloe-R.png", CV_LOAD_IMAGE_GRAYSCALE);
        img_template = readImage("stereobm/aloe-disp.png", CV_LOAD_IMAGE_GRAYSCALE);
        
        ASSERT_FALSE(img_l.empty());
        ASSERT_FALSE(img_r.empty());
        ASSERT_FALSE(img_template.empty());
    }
Beispiel #9
0
void MainWindow::on_actionInsert_Image_triggered()
{
    // imageBefore not loaded:
    if (imageBefore.isNull())
    {
        QMessageBox::information(this, tr("ERROR"),tr("First you must open the image in which you want to hide another."));
        return;
    }
    QMessageBox::information(this, tr("Choose file to hide..."),tr("REMEMBER: \n Chosen file must be much smaller than the image in which you want to hide it."));
    QString imageToHidePath = QFileDialog::getOpenFileName(this, tr("Open File"), QDir::currentPath(),tr("Image (*.jpg *.bmp *.png)"));
    if ( imageToHidePath != "" )
    {
        //load and show image to hide in After window:
        readImage(imageToHidePath,imageAfter);
        showImageAfter();
        if (((imageBefore.byteCount()*3/4)/3)-2 > (imageAfter.byteCount()*3/4))
        {
            // hide imageAfter inside imageBefore:
            Encoder encoder;
            imageAfter = encoder.insertImage(imageBefore,imageAfter);

            //and show it to the user
            showImageAfter();
        }
        else
        {
            QMessageBox::information(this, tr("ERROR"),tr("File to encode is too big."));
        }
    }
}
Beispiel #10
0
void invertImage(FILE *inf, FILE *outf) {
  int i=0;
  int width;
  int height;
  int max;
  int w=0;

  // Get width, height, and max from the file
  rewind(inf);
  eatLine(inf);
  eatLine(inf);
  fscanf(inf,"%d",&width);
  fscanf(inf,"%d",&height);
  fscanf(inf,"%d",&max);

  // Initialize the array
  float *darkValues;
  // Read the values from the pgm file
  darkValues = readImage(inf);
  // Find the total number of 'i's we will have
  int amtValues = width*height;

  // Print the header to our pgm file
  fprintf(outf,"P2\n");
  fprintf(outf,"# CREATOR: BLAKE, THE MASTER OF C\n");
  fprintf(outf,"%d %d\n",width,height);
  fprintf(outf,"%d\n",max);

  // For each pixel, invert the grey value
  while (i < amtValues) {
    fprintf(outf,"%d\n",((int)(max*(1.0-darkValues[i]))));
    i++;
  }
}
Beispiel #11
0
// ---
void QGAMES::ObjectBuilder::preLoad ()
{
	if (_alreadyLoaded)
		return;

	TiXmlDocument doc (_fileName.c_str ());
	int e = doc.LoadFile ();
	assert (e); // Is it a valid doc?
	TiXmlElement* rootElement = doc.RootElement ();
	assert (rootElement); // One element minimum...

	// Reading all elements...
	for (TiXmlElement* groupElement = rootElement -> FirstChildElement ();
		groupElement != NULL; groupElement = groupElement -> NextSiblingElement ())
	{
		QGAMES::Object* obj = NULL;
		if (strcmp (groupElement -> Value (), __QGAMES_IMAGEBLOCK__) == 0)
			obj = readImage (groupElement); // An image...
		if (strcmp (groupElement -> Value (), __QGAMES_BACKGROUNDBLOCK__) == 0)
			obj = readBackground (groupElement); // A background...
		if (strcmp (groupElement -> Value (), __QGAMES_POLYLINEBLOCK__) == 0)
			obj = readGraphicalPolyline (groupElement); // A Polyline...
		if (strcmp (groupElement -> Value (), __QGAMES_POLYGONBLOCK__) == 0)
			obj = readGraphicalPolygon (groupElement); // A Polygon...
		if (strcmp (groupElement -> Value (), __QGAMES_ELLIPSEBLOCK__) == 0)
			obj = readEllipse (groupElement); // An ellipse...
		if (strcmp (groupElement -> Value (), __QGAMES_COMPOSITEBLOCK__) == 0)
			obj = readComposite (groupElement); // A composite made up of all of them...
		assert (obj != NULL);
		_objects.insert (std::map <int, QGAMES::Object*>::value_type (obj -> id (), obj));
	}

	_alreadyLoaded = true;
}
Beispiel #12
0
int learnImage(const char * filename ,unsigned int numberOfHorizontalTiles,unsigned int numberOfVerticalTiles)
{
   struct Image * inputImage = readImage(filename,guessFilenameTypeStupid(filename),0);
   if (inputImage!=0)
   {
     unsigned int tileWidth =inputImage->width/numberOfHorizontalTiles;
     unsigned int tileHeight=inputImage->height/numberOfVerticalTiles;
     fprintf(stderr,"Sucessfully opened image ( %ux%u ) , each tile is %ux%u ..\n",inputImage->width,inputImage->height,tileWidth,tileHeight);


     unsigned int x,y,i=0;
     for (y=0; y<numberOfVerticalTiles; y++)
     {
      for (x=0; x<numberOfHorizontalTiles; x++)
      {
        struct Image * part = createImageBitBlt(inputImage,x*tileWidth , y*tileHeight , tileWidth, tileHeight);
        if (part!=0)
        {
          char tileString[512]={0};
          snprintf(tileString,512,"tile-%05d.jpg",i);
          writeImageFile(part,JPG_CODEC,tileString);
          destroyImage(part);
        }
       ++i;
      }
     }


     destroyImage(inputImage);
     return 1;
   }
  return 0;
}
Beispiel #13
0
/**
 * Main program
 * @param  argc Number of command line arguments, inlucing the program itself.
 * @param  argv Vector of command line arguments.
 * @return      EXIT_SUCCESS if program exits normally, EXIT_ERROR otherwise.
 */
int main(int argc, char** argv) {
  if(argc < 2 || argc > 3) {
    std::cout << "Usage: warper input_image [ouput_image]" << std::endl;
    return EXIT_FAILURE;
  }

  readImage(argv[1]);

  dumbProcess();

  // Flip for openGL
  openGLFlip();

  // Init OpenGL
  glutInit(&argc, argv);
  openGLSetup(width, height);

  if(argc == 3) {
    outImage = argv[2];
    canWrite = true;
  }

  // Start running display window
  glutMainLoop();

  return EXIT_SUCCESS;
}
Beispiel #14
0
AReader::Error ReaderPng::read( imageCache &cache, const uint8_t* data, unsigned length, QString format ) const{
	if( !can_read( data, length, format ) )
		return ERROR_TYPE_UNKNOWN;
	
	// Initialize libpng
	PngInfo png;
	if( !png.isValid() )
		return ERROR_INITIALIZATION;
	
	//Handle errors
	if( setjmp( png_jmpbuf( png.png ) ) )
		return ERROR_FILE_BROKEN;
	
	//Prepare reading
	MemStream stream = { 8, data, length };
	png_set_read_fn( png.png, &stream, read_from_mem_stream );
	png_set_sig_bytes( png.png, 8 ); //Ignore the first 8 bytes
	
	//Start reading
	png_read_info( png.png, png.info );
#ifdef PNG_APNG_SUPPORTED
	if( png_get_valid( png.png, png.info, PNG_INFO_acTL ) )
		readAnimated( cache, png );
	else
#endif
	{
		cache.set_info( 1 );
		readImage( png, png.width(), png.height() );
		cache.add_frame( png.frame, 0 );
	}
	
	//Cleanup and return
	cache.set_fully_loaded();
	return ERROR_NONE;
}
Beispiel #15
0
int main(int argc, char *argv[])
{
	char *iim, *idb, * oim;
	ObjectDB newobjs, known;
	Image im;

	if (argc != 4) {
		fprintf(stderr, "usage: %s <input labeled image> <input database> <output image>", argv[0]);
	}

	iim=argv[1];
	idb=argv[2];
	oim=argv[3];

	readImage(&im, iim);
	readDatabase(&known, idb); /* get the database of known objects */
	makeODB(&newobjs, getColors(&im)); /* create the database for the input image */
	getObjects(&im, &newobjs); /* fill the database for the input image */
	filterObjects(&im, &newobjs, &known); /* find known objects in the database and throw away those unknown */
	drawLines(&im, &newobjs); /* draw lines in the input image */
	writeImage(&im, oim); /* write the output image */

	free(newobjs.objs);
	free(known.objs);
	free(im.data);

	return 0;
}
Beispiel #16
0
int main(int argc, char **argv) {

    int i;
    int window;
    int threshold;
    FILE *a;
    double noise[] = {0.0,0.05,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.45,0.50};
    double *scores;
    portImage *pa;
    a = fopen(argv[1], "r");
    sscanf(argv[2], "%d", &window);
    pa = readImage(a);

    scores = (double*)malloc( sizeof(double) * window * window );
    if (!scores) {
        fprintf(stderr, "Memory allocation failed.\n");
        return 1;
    }

    for (i = 0; i < 11; i++) { 
        printf("%s,%2.2f,", argv[1], noise[i]);
        calculateAverageDifference(pa, window, noise[i], scores);
        for (threshold = 0; threshold < window*window; threshold++)
            printf("%.3f,",scores[threshold]);
        printf("\n");
    }

    free(scores);
    freeImage(pa);
    fclose(a);
    return 0;
} // End Main
void OpenCVPicture::loadData(int scale, int flags) {
  readImage(filename, mat, flags);
  float s = scale * 1.0f / std::min(mat.rows, mat.cols);
  transformImage(mat, backgroundColor, s, 0, 0, s);
  xOffset = -mat.cols / 2;
  yOffset = -mat.rows / 2;
}
Beispiel #18
0
int main(int argc, char *argv[])
{
	if(argc < 2)
		return -1;
	
	// disable buffer on stdout to make 'printf' outputs
	// immediately displayed in GUI-console
	setbuf(stdout, NULL);
	char * image = argv[1];

	// initializations section

	// processings section

	cv::Mat block1_out1;
	//readImage( "/Shared/TP_VTDVR/LIRIS-VISION/Applications/Starling/resource/guardians.jpg", &block1_out1);
	
	readImage( image, &block1_out1);
	cv::Mat block4_out1;
	cv::cvtColor( *(&block1_out1), *(&block4_out1), CV_BGR2GRAY, 0);
	showImage( "block2 (ESC to stop, SPACE to pause)", &block4_out1);

	cv::waitKey(0);

	// cleanings section

	return 0;
}
Beispiel #19
0
GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size)
{
    cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
    cv::gpu::setDevice(devInfo.deviceID());

    cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE);

    cv::threshold(image, image, 150, 255, CV_THRESH_BINARY);

    cv::gpu::GpuMat mask;
    mask.create(image.rows, image.cols, CV_8UC1);

    cv::gpu::GpuMat components;
    components.create(image.rows, image.cols, CV_32SC1);

    cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));

    ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));

    declare.time(1.0);

    TEST_CYCLE()
    {
        cv::gpu::labelComponents(mask, components);
    }
}
int 
ImageOverlap::setup()
{
    int status = 0;
    // Allocate host memoryF and read input image
    std::string filePath = sampleCommon->getPath() + std::string(MAP_IMAGE);
	std::string  verifyfilePath = sampleCommon->getPath() + std::string(MAP_VERIFY_IMAGE);
    status = readImage(filePath,verifyfilePath);
    CHECK_ERROR(status, SDK_SUCCESS, "Read Map Image failed");

	// create and initialize timers
    int timer = sampleCommon->createTimer();
    sampleCommon->resetTimer(timer);
    sampleCommon->startTimer(timer);

    status = setupCL();
    if(status != SDK_SUCCESS)
        return status;
    
    sampleCommon->stopTimer(timer);
    // Compute setup time
    setupTime = (double)(sampleCommon->readTimer(timer));

    return SDK_SUCCESS;
}
Beispiel #21
0
    virtual void test_by_pict()
    {
        Mat frame1 = readImage("optflow/RubberWhale1.png", IMREAD_GRAYSCALE);

        UMat usrc;
        frame1.copyTo(usrc);
        int histSize = randomInt(3, 29);
        float hue_range[] = { 0, 180 };
        const float* ranges1 = { hue_range };
        Mat hist1;

        //compute histogram
        calcHist(&frame1, 1, 0, Mat(), hist1, 1, &histSize, &ranges1, true, false);
        normalize(hist1, hist1, 0, 255, NORM_MINMAX, -1, Mat());

        Mat dst1;
        UMat udst1, src, uhist1;
        hist1.copyTo(uhist1);
        std::vector<UMat> uims;
        uims.push_back(usrc);
        std::vector<float> urngs;
        urngs.push_back(0);
        urngs.push_back(180);
        std::vector<int> chs;
        chs.push_back(0);

        OCL_OFF(calcBackProject(&frame1, 1, 0, hist1, dst1, &ranges1, 1, true));
        OCL_ON(calcBackProject(uims, chs, uhist1, udst1, urngs, 1.0));
        EXPECT_MAT_NEAR(dst1, udst1, 0.0);
    }
Beispiel #22
0
int main(int argc, char *argv[])
{
	char *ifname, *odname, *ofname;
	ObjectDB odb;
	Image im;

	if (argc < 4) {
		fprintf(stderr, "usage: %s <input labeled image> <output database> <output image>", argv[0]);
		return 1;
	}

	ifname=argv[1];
	odname=argv[2];
	ofname=argv[3];

	readImage(&im, ifname);
	makeODB(&odb, getColors(&im));
	getObjects(&im, &odb);
	writeDatabase(&odb, odname);
	drawLines(&im, &odb);
	writeImage(&im, ofname);

	free(odb.objs);
	free(im.data);

	return 0;
}
Beispiel #23
0
ImageLoader::Status ImageLoader::get(QImage &image) const
{
    if (!ok()) return NETWORK_ERROR;

    QByteArray request("GET@"), response;
    request.append(number(mId), sizeof(mId));

    if (!doRequest(request, response))
        return NETWORK_ERROR;

    const int bytesSize = 3 * sizeImage.height * sizeImage.width;
    const int gotBytesSize = response.size();
    if (gotBytesSize == bytesSize)
    {
        qDebug() << "got image";
        image = readImage(response).copy();
        return SUCCESS;
    }
    else if (gotBytesSize == 4 && response == "->-@")
    {
        qDebug() << "done";
        return DONE;
    }
    return NETWORK_ERROR;
}
Beispiel #24
0
void fileManager::readFullTract( const std::string fullTractFilename, compactTract* tractPointer ) const
{
    compactTract& tractogram = *tractPointer;
    std::vector<std::vector<std::vector<float> > > fullTractMatrix;
    ValueType fulltractValueType = readImage(fullTractFilename,&fullTractMatrix);

    if ( fulltractValueType == VTError )
    {
        throw std::runtime_error( "ERROR @ fileManager::readFullTract(): Failed to read full tract image" );
    }
    if ( fulltractValueType != VTFloat32 && fulltractValueType != VTUINT8 )
    {
        throw std::runtime_error("ERROR @ fileManager::readFullTract(): tract representation type not recognized (neither Float32 nor UINT8)");
    }

    full2compact( fullTractMatrix, &(tractogram.m_tract) );
    tractogram.m_inLogUnits = m_logFlag;
    tractogram.m_norm = 0;
    tractogram.m_normReady = false;
    tractogram.m_thresholded = m_thresFlag;

    if ( fulltractValueType == VTUINT8 )
    {
        for( int i = 0; i < tractogram.m_tract.size(); ++i )
        {
            tractogram.m_tract[i] = tractogram.m_tract[i]/255.;
        }
    }
    return;
}// end fileManager::readFullTract() -----------------------------------------------------------------
Beispiel #25
0
static float run(const char* infile, const char* outfile1, const char* outfile2, bool doInterop)
{
    VASurfaceID surface;
    VAStatus status;
    Timer t;

    // initialize CL context for CL/VA interop
    cv::va_intel::ocl::initializeContextFromVA(va::display, doInterop);

    // load input image
    cv::UMat u1 = readImage(infile);
    cv::Size size2 = u1.size();
    status = vaCreateSurfaces(va::display, VA_RT_FORMAT_YUV420, size2.width, size2.height, &surface, 1, NULL, 0);
    CHECK_VASTATUS(status, "vaCreateSurfaces");

    // transfer image into VA surface, make sure all CL initialization is done (kernels etc)
    cv::va_intel::convertToVASurface(va::display, u1, surface, size2);
    cv::va_intel::convertFromVASurface(va::display, surface, size2, u1);
    cv::UMat u2;
    cv::blur(u1, u2, cv::Size(7, 7), cv::Point(-3, -3));

    // measure performance on some image processing
    writeImage(u1, outfile1, doInterop);
    t.start();
    cv::va_intel::convertFromVASurface(va::display, surface, size2, u1);
    cv::blur(u1, u2, cv::Size(7, 7), cv::Point(-3, -3));
    cv::va_intel::convertToVASurface(va::display, u2, surface, size2);
    t.stop();
    writeImage(u2, outfile2, doInterop);

    vaDestroySurfaces(va::display, &surface,1);

    return t.time(Timer::MSEC);
}
Beispiel #26
0
TEST_P(HistEven, Accuracy)
{
    cv::Mat img = readImage("stereobm/aloe-L.png");
    ASSERT_FALSE(img.empty());

    cv::Mat hsv;
    cv::cvtColor(img, hsv, CV_BGR2HSV);

    int hbins = 30;
    float hranges[] = {0.0f, 180.0f};

    std::vector<cv::gpu::GpuMat> srcs;
    cv::gpu::split(loadMat(hsv), srcs);

    cv::gpu::GpuMat hist;
    cv::gpu::histEven(srcs[0], hist, hbins, (int)hranges[0], (int)hranges[1]);

    cv::MatND histnd;
    int histSize[] = {hbins};
    const float* ranges[] = {hranges};
    int channels[] = {0};
    cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges);

    cv::Mat hist_gold = histnd;
    hist_gold = hist_gold.t();
    hist_gold.convertTo(hist_gold, CV_32S);

    EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
}
Beispiel #27
0
GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize)
{
    cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
    cv::gpu::setDevice(devInfo.deviceID());

    int type = GET_PARAM(1);
    int borderType = GET_PARAM(2);
    int blockSize = GET_PARAM(3);
    int apertureSize = GET_PARAM(4);

    cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
    ASSERT_FALSE(img.empty());

    img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);

    cv::gpu::GpuMat src(img);
    cv::gpu::GpuMat dst;
    cv::gpu::GpuMat Dx;
    cv::gpu::GpuMat Dy;
    cv::gpu::GpuMat buf;

    cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, buf, blockSize, apertureSize, borderType);

    TEST_CYCLE()
    {
        cv::gpu::cornerMinEigenVal(src, dst, Dx, Dy, buf, blockSize, apertureSize, borderType);
    }
}
Beispiel #28
0
int histogramme(const char * imageName,int * his,int m,int n){
	targa_header * pHead= (targa_header *) malloc(sizeof(targa_header));
	image_desc * pDesc=(image_desc *) malloc(sizeof(image_desc));	
	if (readImage(pDesc,pHead, imageName)!=1){
		perror("Read file failed!");
	}else{
		int i,j;
		int a,b;
		memset(his,0,3*256*sizeof(int));
		for (i=0;i<pDesc->width*pDesc->height;i++){
			(*(his+0*n+*(pDesc->pRed+i)))++;
			(*(his+1*n+*(pDesc->pRed+i)))++;
			(*(his+2*n+*(pDesc->pRed+i)))++;
	/*
			his[0][*(pDesc->pRed+i)]++;
			his[1][*(pDesc->pGreen+i)]++;
			his[2][*(pDesc->pBlue+i)]++;	
	*/
		}
		
	
	}
	return pDesc->width*pDesc->height;

}
QPixmap MLocalThemeDaemonClient::requestPixmap(const QString &id, const QSize &requestedSize)
{
    QPixmap pixmap;

    QSize size = requestedSize;
    if (size.width() < 1) {
        size.rwidth() = 0;
    }
    if (size.height() < 1) {
        size.rheight() = 0;
    }

    const PixmapIdentifier pixmapId(id, size);
    pixmap = m_pixmapCache.value(pixmapId);
    if (pixmap.isNull()) {
        // The pixmap is not cached yet. Decode the image and
        // store it into the cache as pixmap.
        const QImage image = readImage(id);
        if (!image.isNull()) {
            pixmap = QPixmap::fromImage(image);
            if (requestedSize.isValid() && (pixmap.size() != requestedSize)) {
                pixmap = pixmap.scaled(requestedSize);
            }

            m_pixmapCache.insert(pixmapId, pixmap);
        }
    }
    return pixmap;
}
Beispiel #30
0
    void readRealTestData()
    {
        Mat img = readImage("shared/pic5.png", IMREAD_GRAYSCALE);
        Canny(img, src, 100, 150, 3);

        src.copyTo(usrc);
    }