예제 #1
0
void 
pickRects(int button, int state, int x, int y)
{
  GLuint selectBuf[BUFSIZE];
  GLint hits;
  GLint viewport[4];

  if (button != GLUT_LEFT_BUTTON || state != GLUT_DOWN)
    return;

  glGetIntegerv(GL_VIEWPORT, viewport);

  glSelectBuffer(BUFSIZE, selectBuf);
  (void) glRenderMode(GL_SELECT);

  glInitNames();
  glPushName((GLuint) ~0);

  glMatrixMode(GL_PROJECTION);
  glPushMatrix();
  glLoadIdentity();
/*  create 5x5 pixel picking region near cursor location */
  gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] - y),
    5.0, 5.0, viewport);
  glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5);
  drawRects(GL_SELECT);
  glPopMatrix();
  glFlush();

  hits = glRenderMode(GL_RENDER);
  processHits(hits, selectBuf);
}
예제 #2
0
void 
display(void)
{
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  drawRects(GL_RENDER);
  glutSwapBuffers();
}
void pickRects(AUX_EVENTREC *event)
{
    GLuint selectBuf[BUFSIZE];
    GLint hits;
    GLint viewport[4];
    int x, y;

    x = event->data[AUX_MOUSEX];
    y = event->data[AUX_MOUSEY];
    glGetIntegerv (GL_VIEWPORT, viewport);

    glSelectBuffer (BUFSIZE, selectBuf);
    (void) glRenderMode (GL_SELECT);

    glInitNames();
    glPushName(-1);

    glMatrixMode (GL_PROJECTION);
    glPushMatrix ();
    glLoadIdentity ();
/*  create 5x5 pixel picking region near cursor location	*/
    gluPickMatrix ((GLdouble) x, (GLdouble) (viewport[3] - y), 
	5.0, 5.0, viewport);
    glOrtho (0.0, 8.0, 0.0, 8.0, -0.5, 2.5);
    drawRects (GL_SELECT);
    glPopMatrix ();
    glFlush ();

    hits = glRenderMode (GL_RENDER);
    processHits (hits, selectBuf);
} 
예제 #4
0
int main() {
    const int ballsCount = 20;
    const int rectsCount = 2;
    const int SLEEP_TIME = 1;

    /* initialize system objects */
    Ball ballsArr[ballsCount];
    srand(time(NULL));

    Rect rects[rectsCount];
    rects[0].X = 10;
    rects[0].Y = 5;
    rects[0].Width = 25;
    rects[0].Height = 10;

    rects[1].X = 50;
    rects[1].Y = 5;
    rects[1].Width = 15;
    rects[1].Height = 5;

    initAll(ballsCount, ballsArr, rectsCount, rects);

    /* infinite loop engine */
    while(1) {
        clearScreen();
        drawRects(2, rects);
        updateBalls(ballsCount, ballsArr, rectsCount, rects);
        drawBalls(ballsCount, ballsArr);
        tSleep(SLEEP_TIME);
    }
    return EXIT_SUCCESS;
}
예제 #5
0
void QPdfEngine::drawTiledPixmap (const QRectF &rectangle, const QPixmap &pixmap, const QPointF &point)
{
    Q_D(QPdfEngine);

    bool bitmap = (pixmap.depth() == 1);
    QBrush b = d->brush;
    QPointF bo = d->brushOrigin;
    bool hp = d->hasPen;
    d->hasPen = false;
    bool hb = d->hasBrush;
    d->hasBrush = true;

    d->brush = QBrush(pixmap);
    if (bitmap)
        // #### fix bitmap case where we have a brush pen
        d->brush.setColor(d->pen.color());

    d->brushOrigin = -point;
    *d->currentPage << "q\n";
    setBrush();

    drawRects(&rectangle, 1);
    *d->currentPage << "Q\n";

    d->hasPen = hp;
    d->hasBrush = hb;
    d->brush = b;
    d->brushOrigin = bo;
}
예제 #6
0
bool Sample_13_6::sendMessage(int message, int mode, int x, int y)
{
	GLuint selectBuf[BUFSIZE];
	GLint hits;
	GLint viewport[4];

	switch (message) {
	case SDL_BUTTON_LEFT:
		/*  sets up selection mode, name stack,
		 *  and projection matrix for picking.  Then the
		 *  objects are drawn.
		 */
		if (mode==SDL_PRESSED) {
			glGetIntegerv(GL_VIEWPORT, viewport);

			glSelectBuffer(BUFSIZE, selectBuf);
			(void) glRenderMode(GL_SELECT);

			glInitNames();
			glPushName(0);

			glMatrixMode(GL_PROJECTION);
			glPushMatrix();
			glLoadIdentity();
			/*  create 5x5 pixel picking region near cursor location */
			gluPickMatrix((GLdouble) x, (GLdouble) (viewport[3] - y),
					5.0, 5.0, viewport);
			glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5);
			drawRects(GL_SELECT);
			glPopMatrix();

			hits = glRenderMode(GL_RENDER);
			processHits(hits, selectBuf);
		}
		break;
	default:
		return false;
		break;
	}

	return true;
}
예제 #7
0
/*!
    \overload

    The default implementation converts the first \a rectCount
    rectangles in the buffer \a rects to a QRectF and calls the
    floating point version of this function.
*/
void QPaintEngine::drawRects(const QRect *rects, int rectCount)
{
    struct RectF {
        qreal x;
        qreal y;
        qreal w;
        qreal h;
    };
    Q_ASSERT(sizeof(RectF) == sizeof(QRectF));
    RectF fr[256];
    while (rectCount) {
        int i = 0;
        while (i < rectCount && i < 256) {
            fr[i].x = rects[i].x();
            fr[i].y = rects[i].y();
            fr[i].w = rects[i].width();
            fr[i].h = rects[i].height();
            ++i;
        }
        drawRects((QRectF *)(void *)fr, i);
        rects += i;
        rectCount -= i;
    }
}
예제 #8
0
void show(void)
{
  if(!existImage || !existPoints){
    return;
  }
  const auto& encoding = sensor_msgs::image_encodings::BGR8;
  cv_bridge::CvImagePtr cv_image = cv_bridge::toCvCopy(image_msg, encoding);
  IplImage frame = cv_image->image;

  cv::Mat matImage = cv::cvarrToMat(&frame);//(&frame, false);

  /* DRAW RECTANGLES of detected objects */
#if 0
  for(std::size_t i=0; i<cars.size();i++) {
      if(cars[i].y > matImage.rows*.3) { //temporal way to avoid drawing detections in the sky
          cvRectangle( &frame,
                       cvPoint(cars[i].x, cars[i].y),
                       cvPoint(cars[i].x+cars[i].width, cars[i].y+cars[i].height),
                       _colors[0], 3, 8,0 );
    }
  }
  for(std::size_t i=0; i<peds.size();i++) {
    if(peds[i].y > matImage.rows*.3) {
      cvRectangle( &frame,
                   cvPoint(peds[i].x, peds[i].y),
                   cvPoint(peds[i].x+peds[i].width, peds[i].y+peds[i].height),
                   _colors[1], 3, 8,0 );
    }
  }
#else
  drawRects(&frame,
            car_fused_objects.obj,
            cvScalar(255.0, 255.0, 0,0),
            matImage.rows*.10);

  drawRects(&frame,
            pedestrian_fused_objects.obj,
            cvScalar(0.0, 255.0, 0,0),
            matImage.rows*.10);
#endif
  /* PUT DISTANCE text on image */
  putDistance(&frame,
              car_fused_objects.obj,
              matImage.rows*.10,
              car_fused_objects.type.c_str());
  putDistance(&frame,
              pedestrian_fused_objects.obj,
              matImage.rows*.10,
              pedestrian_fused_objects.type.c_str());

  /* DRAW POINTS of lidar scanning */
  int w = matImage.size().width;
  int h = matImage.size().height;

  int n = w * h;
  float min_d = 1<<16, max_d = -1;
  //	int min_i = 1<<8, max_i = -1;
  for(int i=0; i<n; i++){
    int di = points_msg->distance[i];
    max_d = di > max_d ? di : max_d;
    min_d = di < min_d ? di : min_d;
    // int it = points_msg->intensity[i];
    // max_i = it > max_i ? it : max_i;
    // min_i = it < min_i ? it : min_i;
  }
  float wid_d = max_d - min_d;

  for(int y=0; y<h; y++){
    for(int x=0; x<w; x++){
      int j = y * w + x;
      double distance = points_msg->distance[j];
      if(distance == 0){
        continue;
      }
      int colorid= wid_d ? ( (distance - min_d) * 255 / wid_d ) : 128;
      cv::Vec3b color=colormap.at<cv::Vec3b>(colorid);
      int g = color[1];
      int b = color[2];
      int r = color[0];
      cvRectangle(&frame, cvPoint(x, y), cvPoint(x+1, y+1), CV_RGB(r, g, b));
    }
  }

  if (cvGetWindowHandle(window_name) != NULL) // Guard not to write destroyed window by using close button on the window
    {
      cvShowImage(window_name, &frame);
      cvWaitKey(2);
    }
}
예제 #9
0
void CProgressBar::paintEvent(QPaintEvent *e)
{
    QPainter painter(this);
    drawBackground(&painter);
    drawRects(&painter);
}
예제 #10
0
void display(void)
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   drawRects(GL_RENDER);
   glFlush();
}
예제 #11
0
void Sample_13_6::draw()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	drawRects(GL_RENDER);
}
예제 #12
0
static void show()
{
    if(!exist_image || !exist_scan){
        return;
    }

    IplImage* image_view = cvCreateImage(cvGetSize(&image), image.depth, image.nChannels);
    cvCopy(&image, image_view);

	float min_d, max_d;
	min_d = max_d = scan_image.distance.at(0);
	for(int i = 1; i < IMAGE_WIDTH * IMAGE_HEIGHT; i++){
		float di = scan_image.distance.at(i);
		max_d = di > max_d ? di : max_d;
		min_d = di < min_d ? di : min_d;
	}
	float wid_d = max_d - min_d;

    /*
     * Plot depth points on an image
     */
    CvPoint pt;
    int height, width;
    for(int i = 0; i < (int)scan_image.distance.size(); i++) {
        height = (int)(i % IMAGE_HEIGHT);
        width = (int)(i / IMAGE_HEIGHT);
        if(scan_image.distance.at(i) != 0.0) {
            pt.x = width;
            pt.y = height;
			int colorid= wid_d ? ( (scan_image.distance.at(i) - min_d) * 255 / wid_d ) : 128;
			cv::Vec3b color=colormap.at<cv::Vec3b>(colorid);
			int g = color[1];
			int b = color[2];
			int r = color[0];
            cvCircle(image_view, pt, 2, CV_RGB (r, g, b), CV_FILLED, 8, 0);
        }
    }


  drawRects(image_view,
            car_fused_objects.obj,
            cvScalar(255.0, 255.0, 0,0),
            (image_view->height)*.3);

  drawRects(image_view,
            pedestrian_fused_objects.obj,
            cvScalar(0.0, 255.0, 0,0),
            (image_view->height)*.3);
  /* PUT DISTANCE text on image */
  putDistance(image_view,
              car_fused_objects.obj,
              (image_view->height)*.3,
              car_fused_objects.type.c_str());
  putDistance(image_view,
              pedestrian_fused_objects.obj,
              (image_view->height)*.3,
              pedestrian_fused_objects.type.c_str());

    /*
     * Show image
     */
    cvShowImage(window_name, image_view);
    cvWaitKey(2);
    cvReleaseImage(&image_view);
}
예제 #13
0
int Detector::batchDetect(const string &src_image_folder, const string &dst_image_folder)
{
	if (access(src_image_folder.c_str(), 0) == -1)
	{
		return 0;
	}

	if (access(dst_image_folder.c_str(), 0) == -1)
	{
		_mkdir(dst_image_folder.c_str());
	}


	const int MAX_DETECTION = 500;
	CB_RectT rects[MAX_DETECTION];

	_chdir(src_image_folder.c_str());
	CFileFind file_finder;
    bool is_working = file_finder.FindFile();
	int count = 0;
	while (is_working)
	{
		is_working = file_finder.FindNextFile();
		string file_name = file_finder.GetFileName();
		string file_path = file_finder.GetFilePath();

		if (file_name == "." || file_name == ".."|| file_name == "Thumbs.db")
		{
			continue;
		}

		printf("%s\n", file_path.c_str());

		Mat image = imread(file_path, CV_LOAD_IMAGE_GRAYSCALE);
		if (image.data == NULL)
		{
			continue;
		}
		double ratio = 1.0;
		if (param.resize_w > 0 && param.resize_h > 0)
		{
			int w = param.resize_w;
			int h = image.rows * w / image.cols;
			ratio = (double)image.cols / w;
			Size size(w, h);
			resize(image, image, size);
		}

		param.hot_rect.top *= (image.rows / 100);
		param.hot_rect.bottom *= (image.rows / 100);
		param.hot_rect.left *= (image.cols / 100);
		param.hot_rect.right = (image.cols / 100);

		int subwin_count;
		int num = detect(image, MAX_DETECTION, rects, subwin_count);

		Mat dst_image = imread(file_path, CV_LOAD_IMAGE_COLOR);
		file_path = dst_image_folder + "\\" + file_name;
		drawRects(dst_image, num, rects, Scalar(0, 255, 0), 3, ratio);
		
		num = merger.merge(num, rects);
		drawRects(dst_image, num, rects, Scalar(0, 0, 255), 7, ratio);

		imwrite(file_path, dst_image);
		count++;
 	}
	return 1;
}