Esempio n. 1
0
static void paintStuff(QPainter *p)
{
    QPaintDevice *screenDevice = QApplication::desktop();
    p->drawRect(scaleRect(QRectF(100, 100, 100, 100), screenDevice, p->device()));
    p->save();
    p->translate(scalePoint(QPointF(10, 10), screenDevice, p->device()));
    p->restore();
    p->drawRect(scaleRect(QRectF(100, 100, 100, 100), screenDevice, p->device()));
}
Esempio n. 2
0
void ScalePicker::mouseDblClicked(const QwtScaleWidget *scale, const QPoint &pos)
{
	if (scaleRect(scale).contains(pos) ) 
		emit axisDblClicked(scale->alignment());
	else
	{// Click on the title
		switch(scale->alignment())   
		{
			case QwtScaleDraw::LeftScale:
				{
					emit yAxisTitleDblClicked();
					break;
				}
			case QwtScaleDraw::RightScale:
				{
					emit rightAxisTitleDblClicked();
					break;
				}
			case QwtScaleDraw::BottomScale:
				{
					emit xAxisTitleDblClicked();
					break;
				}
			case QwtScaleDraw::TopScale:
				{
					emit topAxisTitleDblClicked();
					break;
				}
		}
	}
}
void ScalePicker::mouseDblClicked(const QwtScaleWidget *scale, const QPoint &pos)
{
	if (titleRect(scale).contains(pos))
		emit axisTitleDblClicked();
	else if (scaleRect(scale).contains(pos))
        emit axisDblClicked(scale->alignment());
}
void QwtPlotZoomer::rescale()
{
    QwtPlot *plt = plot();
    if ( !plt )
        return;

    const QRectF &rect = d_data->zoomStack[d_data->zoomRectIndex];
    if ( rect != scaleRect() )
    {
        const bool doReplot = plt->autoReplot();
        plt->setAutoReplot( false );

        double x1 = rect.left();
        double x2 = rect.right();
        if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() )
            qSwap( x1, x2 );

        plt->setAxisScale( xAxis(), x1, x2 );

        double y1 = rect.top();
        double y2 = rect.bottom();
        if ( !plt->axisScaleDiv( yAxis() ).isIncreasing() )
            qSwap( y1, y2 );

        plt->setAxisScale( yAxis(), y1, y2 );

        plt->setAutoReplot( doReplot );

        plt->replot();
    }
}
Esempio n. 5
0
void GfxText32::drawFrame(const Common::Rect &rect, const int16 size, const uint8 color, const bool doScaling) {
	Common::Rect targetRect = doScaling ? scaleRect(rect) : rect;

	SciBitmap &bitmap = *_segMan->lookupBitmap(_bitmap);
	byte *pixels = bitmap.getPixels() + rect.top * _width + rect.left;

	// NOTE: Not fully disassembled, but this should be right
	int16 rectWidth = targetRect.width();
	int16 heightRemaining = targetRect.height();
	int16 sidesHeight = heightRemaining - size * 2;
	int16 centerWidth = rectWidth - size * 2;
	int16 stride = _width - rectWidth;

	for (int16 y = 0; y < size && y < heightRemaining; ++y) {
		memset(pixels, color, rectWidth);
		pixels += _width;
		--heightRemaining;
	}
	for (int16 y = 0; y < sidesHeight; ++y) {
		for (int16 x = 0; x < size; ++x) {
			*pixels++ = color;
		}
		pixels += centerWidth;
		for (int16 x = 0; x < size; ++x) {
			*pixels++ = color;
		}
		pixels += stride;
	}
	for (int16 y = 0; y < size && y < heightRemaining; ++y) {
		memset(pixels, color, rectWidth);
		pixels += _width;
		--heightRemaining;
	}
}
Esempio n. 6
0
void PlotZoomer::zoom(int up)
{
  // FIXME: Save the current zoom window in case it's been panned.
  int zoomIndex = zoomRectIndex();
  if (zoomIndex > 0)
  {
    QStack<QRectF> stack = zoomStack();
    if (zoomIndex < stack.size())
    {
      QRectF r = scaleRect();
      stack[zoomIndex] = r;
      setZoomStack(stack, zoomIndex);
    }
  }

  Super::zoom(up);
  if (zoomRectIndex() == 0)
  {
    if (QwtPlot *plotter = plot())
    {
      plotter->setAxisAutoScale(AxisX);
      plotter->setAxisAutoScale(AxisY);
      plotter->updateAxes();
    }
  }
}
Esempio n. 7
0
void LookAlikeMainPrivate::confirmFace(QUrl picture, QString& contact)
{
    //Confirm in Face Recognizer database
    QString urnImage = urnFromUrl(picture);
    XQFaceRegion region = findRegion(contact, urnImage);
    region.setFaceId(contact);

    //Update XMP metadata image
    QString fileName = picture.toLocalFile();
    QImage image(fileName);
    //Scale face to image dimensions
    QSize originalSize = image.size();
    QSize thumbnailSize = region.sourceImageSize();
    QRect rect = region.faceRect();
    QRect scaledRect = scaleRect(rect, thumbnailSize, originalSize);
    QuillMetadataRegion metadataRegion;
    metadataRegion.setArea(scaledRect);
    metadataRegion.setType(QuillMetadataRegion::RegionType_Face);
    QString contactName = m_faceDatabaseProvider->getContactName(contact);
    metadataRegion.setName(contactName);
    metadataRegion.setExtension("nco:PersonContact", contact);
    QuillMetadataRegionList regionList;
    regionList.append(metadataRegion);
    saveMetadataRegionList(fileName, regionList);
}
void ScalePicker::mouseRightClicked(const QwtScale *scale, const QPoint &pos) 
{
QRect rect = scaleRect(scale);

int margin = 2; // pixels tolerance
rect.setRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin, rect.height() +  2 * margin);

if (rect.contains(pos)) 
	{
	if (scale->position() == QwtScale::Left || scale->position() == QwtScale::Right)
			emit axisRightClicked(scale->position());
	else if (scale->position() == QwtScale::Top)
		emit axisRightClicked(QwtScale::Bottom);
	else if (scale->position() == QwtScale::Bottom)
		emit axisRightClicked(QwtScale::Top);
	}
else
	{
	if (scale->position() == QwtScale::Left || scale->position() == QwtScale::Right)
		emit axisTitleRightClicked(scale->position());
	else if (scale->position() == QwtScale::Top)
		emit axisTitleRightClicked(QwtScale::Bottom);
	else if (scale->position() == QwtScale::Bottom)
		emit axisTitleRightClicked(QwtScale::Top);
	}
}
void QwtPlotZoomer::setAxis( int xAxis, int yAxis )
{
    if ( xAxis != QwtPlotPicker::xAxis() || yAxis != QwtPlotPicker::yAxis() )
    {
        QwtPlotPicker::setAxis( xAxis, yAxis );
        setZoomBase( scaleRect() );
    }
}
Esempio n. 10
0
void ScalePicker::mouseRightClicked(const QwtScaleWidget *scale, const QPoint &pos)
{
	plot()->activateGraph();
	
	if (scaleRect(scale).contains(pos))
		emit axisRightClicked(scale->alignment());
	else
		emit axisTitleRightClicked();
}
Esempio n. 11
0
//! Init the zoomer, used by the constructors
void QwtPlotZoomer::init(int selectionFlags, DisplayMode trackerMode)
{
    d_data = new PrivateData;

    d_data->maxStackDepth = -1;

    setSelectionFlags(selectionFlags);
    setTrackerMode(trackerMode);
    setRubberBand(RectRubberBand);

    setZoomBase(scaleRect());
}
Esempio n. 12
0
void GfxText32::erase(const Common::Rect &rect, const bool doScaling) {
	Common::Rect targetRect = doScaling ? rect : scaleRect(rect);

	byte *bitmap = _segMan->getHunkPointer(_bitmap);
	byte *pixels = bitmap + READ_SCI11ENDIAN_UINT32(bitmap + 28);

	// NOTE: There is an extra optimisation within the SCI code to
	// do a single memset if the scaledRect is the same size as
	// the bitmap, not implemented here.
	Buffer buffer(_width, _height, pixels);
	buffer.fillRect(targetRect, _backColor);
}
/*!
  Reinitialized the zoom stack with scaleRect() as base.

  \sa zoomBase(), scaleRect()

  \warning Calling QwtPlot::setAxisScale() while QwtPlot::autoReplot() is false
           leaves the axis in an 'intermediate' state.
           In this case, to prevent buggy behaviour, you must call
           QwtPlot::replot() before calling QwtPlotZoomer::setZoomBase().
           This quirk will be removed in a future release.

  \sa QwtPlot::autoReplot(), QwtPlot::replot().
*/
void QwtPlotZoomer::setZoomBase()
{
    const QwtPlot *plt = plot();
    if ( !plt )
        return;

    d_data->zoomStack.clear();
    d_data->zoomStack.push(scaleRect());
    d_data->zoomRectIndex = 0;

    rescale();
}
Esempio n. 14
0
void GfxText32::drawFrame(const Common::Rect &rect, const int16 size, const uint8 color, const bool doScaling) {
	Common::Rect targetRect = doScaling ? scaleRect(rect) : rect;

	byte *bitmap = _segMan->getHunkPointer(_bitmap);
	byte *pixels = bitmap + READ_SCI11ENDIAN_UINT32(bitmap + 28);

	// NOTE: Not fully disassembled, but this should be right
	// TODO: Implement variable frame size
	assert(size == 1);
	Buffer buffer(_width, _height, pixels);
	buffer.frameRect(targetRect, color);
}
//! Init the zoomer, used by the constructors
void QwtPlotZoomer::init( bool doReplot )
{
    d_data = new PrivateData;

    d_data->maxStackDepth = -1;

    setTrackerMode( ActiveOnly );
    setRubberBand( RectRubberBand );
    setStateMachine( new QwtPickerDragRectMachine() );

    if ( doReplot && plot() )
        plot()->replot();

    setZoomBase( scaleRect() );
}
/*!
  Reinitialized the zoom stack with scaleRect() as base.

  \param doReplot Call QwtPlot::replot() for the attached plot before initializing
                  the zoomer with its scales. This might be necessary,
                  when the plot is in a state with pending scale changes.

  \sa zoomBase(), scaleRect() QwtPlot::autoReplot(), QwtPlot::replot().
*/
void QwtPlotZoomer::setZoomBase( bool doReplot )
{
    QwtPlot *plt = plot();
    if ( plt == NULL )
        return;

    if ( doReplot )
        plt->replot();

    d_data->zoomStack.clear();
    d_data->zoomStack.push( scaleRect() );
    d_data->zoomRectIndex = 0;

    rescale();
}
Esempio n. 17
0
void Differ::addHighlighting(QRectF *bigRect,
        QPainterPath *highlighted, const QRectF wordOrCharRect,
        const int DPI)
{
    QRectF rect = wordOrCharRect;
    scaleRect(DPI, &rect);
    if (combineHighlightedWords &&
        rect.adjusted(-overlap, -overlap, overlap, overlap)
            .intersects(*bigRect))
    {
        *bigRect = bigRect->united(rect);
    }
    else {
        highlighted->addRect(*bigRect);
        *bigRect = rect;
    }
}
Esempio n. 18
0
void EditFrame::paintEvent(QPaintEvent* /*event*/)
{
	QRect r( rect() );
	r.adjust(0, 0, -1, -1);
	
	QPainter painter(this);
	
	QColor color(m_Selected ? QColor(0,200,60) : QColor(255,255,255));
	
	if( m_Selected )
	{
		QColor fillColor(color);
		fillColor.setAlpha(40);
		painter.fillRect(r, fillColor);
		
		QWidget *pParent = parentWidget();
		if( pParent )
		{
			QRect g( pParent->geometry() );
			QString label = QString("(%1,%2)\n%3x%4").arg(g.x()).arg(g.y()).arg(g.width()).arg(g.height());
			painter.setPen( QColor(0,0,0) );
			painter.drawText(r.adjusted(1,1,1,1), Qt::AlignCenter, label);
			painter.setPen( QColor(255,255,255) );
			painter.drawText(r, Qt::AlignCenter, label);
		}
	}
	
	r.adjust(HANDLE_MARGIN, HANDLE_MARGIN, -HANDLE_MARGIN-1, -HANDLE_MARGIN-1);
	
	for(int i=0; i<2; i++)
	{
		QColor handleColor((i==0) ? QColor(0,0,0) : color);
		
		painter.setBrush(Qt::NoBrush);
		if(i == 0)
			painter.setPen( QPen(handleColor,3) );
		else
			painter.setPen(handleColor);
		painter.drawRect(r);
	
		QRect scaleRect(width()-HANDLE_SIZE-1, height()-HANDLE_SIZE-1, HANDLE_SIZE, HANDLE_SIZE);
		if(i == 0)
			scaleRect.adjust(-1, -1, 1, 1);
		painter.fillRect(scaleRect, handleColor);
	}
}
Esempio n. 19
0
void ScalePicker::mouseClicked( const QwtScaleWidget *scale, const QPoint &pos )
{
    QRect rect = scaleRect( scale );

    int margin = 20; // 20 pixels tolerance
    rect.setRect( rect.x() - margin, rect.y() - margin,
        rect.width() + 2 * margin, rect.height() +  2 * margin );

    if ( rect.contains( pos ) ) // No click on the title
    {
        // translate the position in a value on the scale

        double value = 0.0;
        int axis = -1;

        const QwtScaleDraw *sd = scale->scaleDraw();
        switch( scale->alignment() )
        {
            case QwtScaleDraw::LeftScale:
            {
                value = sd->scaleMap().invTransform( pos.y() );
                axis = QwtPlot::yLeft;
                break;
            }
            case QwtScaleDraw::RightScale:
            {
                value = sd->scaleMap().invTransform( pos.y() );
                axis = QwtPlot::yRight;
                break;
            }
            case QwtScaleDraw::BottomScale:
            {
                value = sd->scaleMap().invTransform( pos.x() );
                axis = QwtPlot::xBottom;
                break;
            }
            case QwtScaleDraw::TopScale:
            {
                value = sd->scaleMap().invTransform( pos.x() );
                axis = QwtPlot::xTop;
                break;
            }
        }
        Q_EMIT clicked( axis, value );
    }
}
void ServerVideoManager::setSharedArea(RECT r,bool sendAreaMsg,int client)
{
	first=true;	// Next set of rectangles detected from Analyzer threads will be ignored
	shared=r;

	r=scaleRect(r,scale_fact);

	if(sendAreaMsg)
	{
		// True when Server is sharing a window, the window has been moved
		// but its size has not been changed (no need for a message VIDEO_AREA)

		char *msg=new char[HEADER_VIDEO_AREA_DIM];

		// Write the control header
		int num;
		num = htons((u_short)HEADER_VIDEO_AREA);
		memcpy(msg,&num,2);	// message code

		num = htons((u_short)(r.right - r.left));
		memcpy(msg+2,&num,2);	// width

		num = htons((u_short)(r.bottom - r.top));
		memcpy(msg+4,&num,2);	// height

		send_wrapper(msg,HEADER_VIDEO_AREA_DIM,client);

		delete[] msg;
	}

	if(enabled)
	{
		int offset_x=r.left;
		int offset_y=r.top;

		r.bottom-=offset_y;
		r.top-=offset_y;
		r.left-=offset_x;
		r.right-=offset_x;

		sendRect(r,offset_x,offset_y,client);
		notifyFinishedRefresh();
	}
}
Esempio n. 21
0
void GfxText32::invertRect(const reg_t bitmapId, int16 bitmapStride, const Common::Rect &rect, const uint8 foreColor, const uint8 backColor, const bool doScaling) {
	Common::Rect targetRect = rect;
	if (doScaling) {
		bitmapStride = bitmapStride * _xResolution / g_sci->_gfxFrameout->getCurrentBuffer().scriptWidth;
		targetRect = scaleRect(rect);
	}

	SciBitmap &bitmap = *_segMan->lookupBitmap(bitmapId);

	// NOTE: SCI code is super weird here; it seems to be trying to look at the
	// entire size of the bitmap including the header, instead of just the pixel
	// data size. We just look at the pixel size. This function generally is an
	// odd duck since the stride dimension for a bitmap is built in to the bitmap
	// header, so perhaps it was once an unheadered bitmap format and this
	// function was never updated to match? Or maybe they exploit the
	// configurable stride length somewhere else to do stair stepping inverts...
	uint32 invertSize = targetRect.height() * bitmapStride + targetRect.width();
	uint32 bitmapSize = bitmap.getDataSize();

	if (invertSize >= bitmapSize) {
		error("InvertRect too big: %u >= %u", invertSize, bitmapSize);
	}

	// NOTE: Actual engine just added the bitmap header size hardcoded here
	byte *pixel = bitmap.getPixels() + bitmapStride * targetRect.top + targetRect.left;

	int16 stride = bitmapStride - targetRect.width();
	int16 targetHeight = targetRect.height();
	int16 targetWidth = targetRect.width();

	for (int16 y = 0; y < targetHeight; ++y) {
		for (int16 x = 0; x < targetWidth; ++x) {
			if (*pixel == foreColor) {
				*pixel = backColor;
			} else if (*pixel == backColor) {
				*pixel = foreColor;
			}

			++pixel;
		}

		pixel += stride;
	}
}
Esempio n. 22
0
void CalcProxyScaleFactor (const VRect *filterRect, Rect *proxyRect, float *scaleFactor)
{

	short filterHeight;
	short filterWidth;
	short itemHeight;
	short itemWidth;
	Point fraction;

	shrinkRect (proxyRect, kGutter, kGutter); 		 // for the border

	filterHeight = (short)(filterRect->bottom - filterRect->top);
	filterWidth  = (short)(filterRect->right  - filterRect->left);
	
	itemHeight = proxyRect->bottom - proxyRect->top;
	itemWidth  = proxyRect->right  - proxyRect->left;
	
	if (itemHeight > filterHeight)
		itemHeight = filterHeight;
		
	if (itemWidth > filterWidth)
		itemWidth = filterWidth;
	
	fraction.h = (short)((filterWidth + itemWidth) / itemWidth);
	fraction.v = (short)((filterHeight + itemHeight) / itemHeight);

	// compute a scale factor now
	if (fraction.h > fraction.v) 
		*scaleFactor = ((float)filterWidth + (float)itemWidth) / (float)itemWidth;
	else
		*scaleFactor = ((float)filterHeight + (float)itemHeight) / (float)itemHeight;

	// resize the proxy rectangle
	copyRect (proxyRect, filterRect);	
	scaleRect (proxyRect, 1, (short)*scaleFactor);

	// now get a more precise scale factor from the resulting rectangle
	if (fraction.h > fraction.v) 
		*scaleFactor = (float)filterWidth / (float)(proxyRect->right  - proxyRect->left);
	else
		*scaleFactor = (float)filterHeight / (float)(proxyRect->bottom - proxyRect->top);

}
char *ServerVideoManager::createVideoMessage(RECT r,int size,int offset_x,int offset_y,int client)
{
	char *msg=new char[HEADER_VIDEO_DATA_DIM+size];

	// Write the control header
	int num;
	num = htons((u_short)HEADER_VIDEO_DATA);
	memcpy(msg,&num,2);	// message code

	num = htons((u_short)(r.left));
	memcpy(msg+2,&num,2);	// rectangle coord x

	num = htons((u_short)(r.top));
	memcpy(msg+4,&num,2);	// rectangle  coord y

	num = htons((u_short)(r.right - r.left));
	memcpy(msg+6,&num,2);	// width

	num = htons((u_short)(r.bottom - r.top));
	memcpy(msg+8,&num,2);	// height

	num = htons((u_short)bytes_per_pixel);
	memcpy(msg+10,&num,2);	// bytes per pixel

	/*
	if(bytes_per_pixel!=4)
		int debug_alert=0;
	*/

	// Add payload
	r.bottom+=offset_y;
	r.top+=offset_y;
	r.left+=offset_x;
	r.right+=offset_x;
	RECT r_unscaled=scaleRect(r,1/scale_fact);

	BYTE *buf=getPartialScreenshot(r_unscaled);
	memcpy(msg+HEADER_VIDEO_DATA_DIM,buf,size);
	delete[] buf;

	return msg;
}
Esempio n. 24
0
Rect OpenCVUtils::calculateROI(Size imgSize, Rect srcRect, double scaleRatio) {

    Rect scaledRect = scaleRect(srcRect, scaleRatio);

    int roi_x=0, roi_y=0, roi_w=0, roi_h=0;

    if(scaledRect.x < 0) roi_x=0;
    else roi_x = scaledRect.x;

    if( (scaledRect.x+scaledRect.width) > imgSize.width ) roi_w = imgSize.width - scaledRect.x;
    else roi_w = scaledRect.width;
                
    if(scaledRect.y<0) roi_y=0;
    else roi_y = scaledRect.y;

    if( (scaledRect.y+scaledRect.height) > imgSize.height ) roi_h = imgSize.height - scaledRect.y;
    else roi_h = scaledRect.height;

    return Rect(roi_x, roi_y, roi_w, roi_h);

}
/*!
  \brief Set the initial size of the zoomer.

  base is united with the current scaleRect() and the zoom stack is
  reinitialized with it as zoom base. plot is zoomed to scaleRect().

  \param base Zoom base

  \sa zoomBase(), scaleRect()
*/
void QwtPlotZoomer::setZoomBase( const QRectF &base )
{
    const QwtPlot *plt = plot();
    if ( !plt )
        return;

    const QRectF sRect = scaleRect();
    const QRectF bRect = base | sRect;

    d_data->zoomStack.clear();
    d_data->zoomStack.push( bRect );
    d_data->zoomRectIndex = 0;

    if ( base != sRect )
    {
        d_data->zoomStack.push( sRect );
        d_data->zoomRectIndex++;
    }

    rescale();
}
void ServerVideoManager::refreshBlocks()
{
	// Send the changed rectangle to the sockets
	if(!first)
	{
		
		RECT shared_scaled=scaleRect(shared,scale_fact);

		for(int i=0;	i<NUM_BLOCKS;	i++)
		{				
			if(	rv[i].top	!=-1	&&
				rv[i].left	!=-1	&&
				rv[i].bottom!=-1	&&
				rv[i].right	!=-1 )
			{
				sendRect(rv[i],shared_scaled.left,shared_scaled.top);
			}
		}

	}else{
		first=false;
	}
	
	
	if(old_bmp != NULL)
		delete[] old_bmp;
	old_bmp = new_bmp;

	// New requests to Anlyzer threads
	completed = 0;
	current_block = 0;
	new_bmp = getScreenshot();
	int thr=0;
	for(int i=0;	i<NUM_BLOCKS;	i++)
	{
		newRequest(thr++);
		if(thr>=THREAD_NUM)
			thr=0;
	}	
}
Esempio n. 27
0
void ScalePicker::mouseDblClicked(const QwtScale *scale, const QPoint &pos) 
{
QRect rect = scaleRect(scale);

int margin = 2; // pixels tolerance
rect.setRect(rect.x() - margin, rect.y() - margin, rect.width() + 2 * margin, rect.height() +  2 * margin);

if ( rect.contains(pos) ) 
	{
	emit axisDblClicked(scale->position());
	}
else
	{// Click on the title
    switch(scale->position())   
        {
        case QwtScale::Left:
            {
			emit yAxisTitleDblClicked();
            break;
            }
        case QwtScale::Right:
            {
			emit rightAxisTitleDblClicked();
            break;
            }
        case QwtScale::Bottom:
            {
			emit xAxisTitleDblClicked();
            break;
            }
        case QwtScale::Top:
            {
			emit topAxisTitleDblClicked();
            break;
            }
		}
	}
}
void ScrollZoomWidget::paintEvent(QPaintEvent * /*paintEvent*/, QPainter & painter)
{
	//draw scroll bar
	UpdateScrollBarPosition();

	//draw slider
	UpdateSliderPosition();

	painter.setPen(Qt::black);
	
	//draw increase box
	{
		painter.setPen(Qt::black);
		QRect increaseRect = GetIncreaseRect();
		painter.drawRect(increaseRect);
		int increaseRectX1;
		int increaseRectY1;
		int increaseRectX2;
		int increaseRectY2;
		increaseRect.getRect(&increaseRectX1, &increaseRectY1, &increaseRectX2, &increaseRectY2);
		int vertLineX1 = increaseRectX1 + increaseRect.width()/2;
		int vertLineY1 = increaseRectY1;
		int vertLineX2 = vertLineX1;
		int vertLineY2 = increaseRectY1+ increaseRectY2;
		painter.drawLine(vertLineX1, vertLineY1, vertLineX2, vertLineY2);
		int horLineX1 = increaseRectX1 ;
		int horLineY1 = increaseRectY1 + increaseRect.height()/2;
		int horLineX2 = increaseRectX1 + increaseRectX2;
		int horLineY2 = horLineY1;
		painter.drawLine(horLineX1, horLineY1, horLineX2, horLineY2);
	}

	//draw scale value
	{
		char scaleChar[10];
		sprintf(scaleChar, "%.0f", scale * 100);
		QString scale(scaleChar);
		painter.setPen(Qt::black);
		QRect scaleRect(GetScaleRect());
		scaleRect.setWidth(SCALE_WIDTH);
		painter.drawText(scaleRect.bottomLeft(), scale);
	}

	//draw decrease box
	{
		painter.setPen(Qt::black);
		QRect decreaseRect = GetDecreaseRect();
		painter.drawRect(decreaseRect);
		int decreaseRectX1;
		int decreaseRectY1;
		int decreaseRectX2;
		int decreaseRectY2;
		decreaseRect.getRect(&decreaseRectX1, &decreaseRectY1, &decreaseRectX2, &decreaseRectY2);
		int horLineX1 = decreaseRectX1 ;
		int horLineY1 = decreaseRectY1 + decreaseRect.height()/2;
		int horLineX2 = decreaseRectX1 + decreaseRectX2;
		int horLineY2 = horLineY1;
		painter.drawLine(horLineX1, horLineY1, horLineX2, horLineY2);
	}
	
}
Esempio n. 29
0
RotatedRect searchFace(Mat& src, GenericModel *model, cv::Size2f scaleFactor, bool draw){
	
	GenericFeature *minFeature;
	Mat auxImg, auxImg2;
	resize(src, auxImg,cv::Size2i(scaleFactor.width*src.size().width, scaleFactor.height*src.size().height));
	auxImg2 = auxImg.clone();
	
	CvHaarClassifierCascade* cascade = (CvHaarClassifierCascade*) cvLoad (CASCADE_NAME, 0, 0, 0);
    CvMemStorage* storage = cvCreateMemStorage(0);
    assert (storage);
	if (! cascade)
        abort ();
	
	CvHaarClassifierCascade* cascadeProfile = (CvHaarClassifierCascade*) cvLoad (CASCADE_NAME_PROFILE, 0, 0, 0);
    CvMemStorage* storageProfile = cvCreateMemStorage(0);
    assert (storageProfile);
	if (! cascadeProfile)
        abort ();
	
	IplImage *gray_image = cvCreateImage(src.size(), IPL_DEPTH_8U, 1);
	IplImage aux = IplImage(src);
	
	cvCvtColor (&aux, gray_image, CV_BGR2GRAY);
	cvEqualizeHist( gray_image, gray_image );
	
	CvSeq* faces = cvHaarDetectObjects (gray_image, cascade, storage, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING, cvSize (25, 25));
	CvSeq* facesProfiles = cvHaarDetectObjects (gray_image, cascadeProfile, storageProfile, 1.1, 3, CV_HAAR_DO_CANNY_PRUNING, cvSize (25, 25));
	
	double minValue = 10000.0;
	RotatedRect minRect;
	
	model->updateModel(auxImg);
	if (draw) cvNamedWindow("ROI");
	
	for (int i = 0; i < (faces ? faces->total : 0); i++){
		CvRect* r = (CvRect*) cvGetSeqElem (faces, i);
		RotatedRect auxRect(Point2i(r->x+r->width/2,r->y+r->height/2),Size2i(r->width,r->height),0);
		auxRect = scaleRect(auxRect, cv::Size2f(scaleFactor.width, scaleFactor.height));
		if (draw) drawRotatedRect(auxImg2, auxRect,CV_RGB(100,50,50) , 2);
		
		
		if(model->ModelType == COV_FULL_IMAGE){
			//minFeature = (GenericFeature *)new CovarianceFullDescriptor(auxRect,model->tracker_param);
			CV_Assert(false);
		}
		else if(model->ModelType == COV_SUB_WINDOWS)
			minFeature = (GenericFeature *)new CovariancePatchDescriptor(auxRect,model->tracker_param);
		else if(model->ModelType == COV_SUB_WINDOWS_B)
			minFeature = (GenericFeature *)new CovariancePatchDescriptor(auxRect,model->tracker_param);
		
		minFeature->computeFeature(model);
		double dist = model->distance(minFeature);
		
		if (dist<minValue) {
			minValue = dist;
			minRect = auxRect;
		}
		
		minFeature->clear();
		delete minFeature;
		if (draw){
			cout << "dist: "<<dist<<endl;
			imshow( "ROI", auxImg2);
			cvWaitKey();
		}
		
	}
	
	for (int i = 0; i < (facesProfiles ? facesProfiles->total : 0); i++){
		CvRect* r = (CvRect*) cvGetSeqElem (facesProfiles, i);
		RotatedRect auxRect(Point2i(r->x+r->width/2,r->y+r->height/2),Size2i(r->width,r->height),0);
		auxRect = scaleRect(auxRect, cv::Size2f(scaleFactor.width, scaleFactor.height));
		if (draw) drawRotatedRect(auxImg2, auxRect,CV_RGB(0,0,0) , 2);
		
		if(model->ModelType == COV_FULL_IMAGE){
			//minFeature = (GenericFeature *)new CovarianceFullDescriptor(auxRect,model->tracker_param);
			CV_Assert(false);
		}
		else if(model->ModelType == COV_SUB_WINDOWS)
			minFeature = (GenericFeature *)new CovariancePatchDescriptor(auxRect,model->tracker_param);
		else if(model->ModelType == COV_SUB_WINDOWS_B)
			minFeature = (GenericFeature *)new CovariancePatchDescriptor(auxRect,model->tracker_param);
		
		minFeature->computeFeature(model);
		double dist = model->distance(minFeature);
		
		
		if (dist<minValue) {
			minValue = dist;
			minRect = auxRect;
		}
		
		minFeature->clear();
		delete minFeature;
		if (draw){
			cout << "dist: "<<dist<<endl;
			imshow( "ROI", auxImg2);
			cvWaitKey();
		}	
	}	
	
	
	if (draw){
		drawRotatedRect(auxImg2, minRect,CV_RGB(255,0,0) , 3);	
		imshow( "ROI", auxImg2);
		cvWaitKey();
		cvDestroyWindow("ROI");
	}
	auxImg2.release();
	auxImg.release();
	
	cvReleaseImage(&gray_image);
	
	cvClearMemStorage(storage);
	cvClearMemStorage(storageProfile);
	
	return scaleRect(minRect, cv::Size2f(1/scaleFactor.width, 1/scaleFactor.height));	
}
Esempio n. 30
0
void GfxText32::erase(const Common::Rect &rect, const bool doScaling) {
	Common::Rect targetRect = doScaling ? scaleRect(rect) : rect;

	SciBitmap &bitmap = *_segMan->lookupBitmap(_bitmap);
	bitmap.getBuffer().fillRect(targetRect, _backColor);
}