// paint is the same as sidebar
void
GcOverlayWidget::paintBackground(QPaintEvent *)
{
    // setup a painter and the area to paint
    QPainter painter(this);

    painter.save();
    QRect all(0,0,width(),height());
    QRect boundary(0,0,width()-1,height()-1);

    painter.fillRect(all, GColor(CPLOTBACKGROUND));
    painter.setPen(QPen(Qt::darkGray));
    painter.drawRect(boundary);

    // linear gradients
    QLinearGradient active = GCColor::linearGradient(23, true); 
    QLinearGradient inactive = GCColor::linearGradient(23, false); 

    // title
    QRect title(0,0,width(),23);
    painter.fillRect(title, QColor(Qt::white));
    painter.fillRect(title, isActiveWindow() ? active : inactive);

    if (!GCColor::isFlat()) {
        QPen black(QColor(100,100,100,200));
        painter.setPen(black);
        painter.drawLine(0,22, width()-1, 22);

        QPen gray(QColor(230,230,230));
        painter.setPen(gray);
        painter.drawLine(0,0, width()-1, 0);
    }

    painter.restore();
}
Example #2
0
File: game.cpp Project: erik/blocks
void Game::CreateMenu() {

    // Create the scene

    context->scene->Init(context);

    // Create the GUI

    sf::Color invis(0, 0, 0, 0);
    sf::Color gray(0x22, 0x22, 0x22, 128);

    sf::Rect<int> rect(200, 200, 600, 250);
    sf::Rect<int> rect2(200, 275, 600, 325);
    sf::Rect<int> rect3(200, 350, 600, 400);

    GUIButton *but =  new GUIButton("START GAME", rect, gray, invis);
    GUIButton *but2 = new GUIButton("OPTIONS",    rect2, gray, invis);
    GUIButton *but3 = new GUIButton("EXIT",       rect3, gray, invis);

    but3->SetOnClick(exitOnClick);
    but->SetOnClick(startGameOnClick);

    but->SetFontSize(20.0f);
    but2->SetFontSize(20.0f);
    but3->SetFontSize(20.0f);

    gui->AddElement(but);
    gui->AddElement(but2);
    gui->AddElement(but3);
}
void
LineSegment2I::TestDraw( )
{
    Color3B gray( 100, 100, 100 );
    Color3B yellow( 255, 255, 0 );
    Color3B magenta( 255, 0, 255 );
    Color3B cyan( 0, 255, 255 );

    int x = 60;
    int y = 20;
    int dx = 100;
    int dy = 80;
    LineSegment2I ln1( x, y, dx, dy );
    int x1 = 160;
    int y1 = 20;
    int x2 = 60;
    int y2 = 100;
    LineSegment2I ln2( Point2I( x1, y1 ), Point2I( x2, y2 ) );

    Rectangle oldClip = Surface::Current()->ClippingRect();
    ln1.Draw( gray );
    ln2.Draw( gray );
    Surface::Current()->SetClippingRect( Rectangle( 100, 50, 20, 20 ) );
    ln1.Draw( yellow );
    ln2.Draw( yellow );
    Surface::Current()->SetClippingRect( Rectangle( 60, 10, 20, 200 ) );
    ln1.Draw( cyan );
    ln2.Draw( cyan );
    Surface::Current()->SetClippingRect( Rectangle( 140, 10, 20, 200 ) );
    ln1.Draw( magenta );
    ln2.Draw( magenta );
    Surface::Current()->SetClippingRect( oldClip );
}
//----------------------------------------------------------------------------
void RoughPlaneThinRod2::OnDisplay ()
{
    ClearScreen();

    ColorRGB black(0, 0, 0);
    ColorRGB gray(128, 128, 128);
    ColorRGB blue(0, 0, 255);

    // Draw the rod.
    double x1, y1, x2, y2;
    mModule.Get(x1, y1, x2, y2);
    int iX1 = (int)(x1 + 0.5);
    int iY1 = (int)(y1 + 0.5);
    int iX2 = (int)(x2 + 0.5);
    int iY2 = (int)(y2 + 0.5);
    DrawLine(iX1, iY1, iX2, iY2, gray);

    // Draw the masses.
    SetThickPixel(iX1, iY1, 2, black);
    SetThickPixel(iX2, iY2, 2, black);

    // Draw the center of mass.
    int x = (int)(mModule.GetX() + 0.5);
    int y = (int)(mModule.GetY() + 0.5);
    SetThickPixel(x, y, 2, blue);

    WindowApplication2::OnDisplay();
}
Example #5
0
void
GcToolBar::paintBackground(QPaintEvent *)
{
    QPainter painter(this);

    // get the widget area
    QRect all(0,0,width(),height());

    // fill with a linear gradient
    QLinearGradient linearGradient = GCColor::linearGradient(23, isActiveWindow());
    
    painter.setPen(Qt::NoPen);
    painter.fillRect(all, linearGradient);

    if (!GCColor::isFlat()) {
        // paint the bottom lines
        QPen black(QColor(100,100,100));
        painter.setPen(black);
        painter.drawLine(0,height()-1, width()-1, height()-1);

#ifndef Q_OS_WIN32 // never on windows.
        QPen gray(QColor(230,230,230));
        painter.setPen(gray);
        painter.drawLine(0,0, width()-1, 0);
#endif
    }
}
//-----------------------------------------------------------------------------
// Purpose: Draw the weapon's crosshair
//-----------------------------------------------------------------------------
void CWeaponIFMSteadyCam::DrawCrosshair( void )
{
	BaseClass::DrawCrosshair();

	int x, y, w, h;
	GetOverlayBounds( x, y, w, h );

	// Draw the targeting zone around the crosshair
	int r, g, b, a;
	gHUD.m_clrYellowish.GetColor( r, g, b, a );
		 
	Color gray( 255, 255, 255, 192 );
	Color light( r, g, b, 255 );
	Color dark( r, g, b, 128 );
	Color red( 255, 0, 0, 128 );
	
	DrawArmLength( x, y, w, h, light );
	DrawFOV( x, y, w, h, light, dark );

	int cx, cy;
	cx = x + ( w / 2 );
	cy = y + ( h / 2 );

	// This is the crosshair
	vgui::surface()->DrawSetColor( gray );
	vgui::surface()->DrawFilledRect( cx-10, cy-1, cx-3, cy+1 );
	vgui::surface()->DrawFilledRect( cx+3, cy-1, cx+10, cy+1 );
	vgui::surface()->DrawFilledRect( cx-1, cy-10, cx+1, cy-3 );
	vgui::surface()->DrawFilledRect( cx-1, cy+3, cx+1, cy+10 );

	// This is the yellow aiming dot
	if ( ( m_vecViewOffset.x != 0.0f ) || ( m_vecViewOffset.y != 0.0f ) )
	{
		int ax, ay;
		ax = cx + m_vecViewOffset.x;
		ay = cy + m_vecViewOffset.y;
		vgui::surface()->DrawSetColor( light );
		vgui::surface()->DrawFilledRect( ax-2, ay-2, ax+2, ay+2 );
	}

	// This is the red actual dot
	if ( ( m_vecActualViewOffset.x != 0.0f ) || ( m_vecActualViewOffset.y != 0.0f ) )
	{
		int ax, ay;
		ax = cx + m_vecActualViewOffset.x;
		ay = cy + m_vecActualViewOffset.y;
		vgui::surface()->DrawSetColor( red );
		vgui::surface()->DrawFilledRect( ax-2, ay-2, ax+2, ay+2 );
	}

	// This is the purple fov dot
	if ( m_flFOVOffsetY != 0.0f )
	{
		Color purple( 255, 0, 255, 255 );
		int vy = cy + m_flFOVOffsetY;
		vgui::surface()->DrawSetColor( purple );
		vgui::surface()->DrawFilledRect( cx-2, vy-2, cx+2, vy+2 );
	}
}
Example #7
0
void drawPattern(Texture& screen) {
  Vect4 black(0.0, 0.0, 0.0), gray(0.125, 0.125, 0.125);
  for (int r = 0; r < screen.height(); r++)
    for (int c = 0; c < screen.width(); c++) {
      if (((r + c) / 5) % 2) screen.setColor(r, c, gray);
      else screen.setColor(r, c, black);
    }  
}
//----------------------------------------------------------------------------
void RoughPlaneParticle1::OnDisplay ()
{
    ClearScreen();

    ColorRGB black(0, 0, 0);
    ColorRGB gray(128, 128, 128);
    ColorRGB blue(0, 0, 128);
    ColorRGB lightBlue(0, 0, 255);
    int x0, w0, x1, w1, i;
    Vector2d position;

    const double xScale = 1.25;
    const double wScale = 0.75;
    const int wOffset = 96;

    // Draw viscous friction path of motion.
    const int numVFPositions = (int)mVFPositions.size();
    position = mVFPositions[0];
    x0 = (int)(xScale*position.X() + 0.5);
    w0 = (int)(wScale*position.Y() + 0.5) + wOffset;
    x1 = x0;
    w1 = w0;
    for (i = 1; i < numVFPositions; ++i)
    {
        position = mVFPositions[i];
        x1 = (int)(xScale*position.X() + 0.5);
        w1 = (int)(wScale*position.Y() + 0.5) + wOffset;
        DrawLine(x0, w0, x1, w1, lightBlue);
        x0 = x1;
        w0 = w1;
    }

    // Draw the mass.
    SetThickPixel(x1, w1, 2, blue);

    // Draw static friction path of motion.
    const int numSFPositions = (int)mSFPositions.size();
    position = mSFPositions[0];
    x0 = (int)(xScale*position.X() + 0.5);
    w0 = (int)(wScale*position.Y() + 0.5) + wOffset;
    x1 = x0;
    w1 = w0;
    for (i = 1; i < numSFPositions; ++i)
    {
        position = mSFPositions[i];
        x1 = (int)(xScale*position.X() + 0.5);
        w1 = (int)(wScale*position.Y() + 0.5) + wOffset;
        DrawLine(x0, w0, x1, w1, gray);
        x0 = x1;
        w0 = w1;
    }

    // Draw the mass.
    SetThickPixel(x1, w1, 2, black);

    WindowApplication2::OnDisplay();
}
Example #9
0
QImage toGrayScale(const QImage& img)
{
    QImage gray(img.size(), QImage::Format_Indexed8);
    gray.setColorTable(grayTable);
    for(int i=0;i<img.width(); ++i)
        for(int j=0; j<img.height(); ++j)
            gray.setPixel(i,j,qGray(img.pixel(i,j)));
    return gray;
}
Example #10
0
void SyntroReview::onClose()
{
	QPixmap gray(size());
	gray.fill(Qt::gray);
	m_cameraView->setPixmap(gray);
	
	emit closeFile();
	m_file->setText("...");
}
Example #11
0
Detector::Status Detector::detectAndDraw()
{
    const Scalar eye_color({0,255,255});
    const Scalar face_color({255,128,0});
    vector<Rect> objects;
    vector<Rect> faces;

    //check the data
    if( eyesCascade.empty() || faceCascade.empty() )
    {
        return StatusNoModel;
    }
    image = imread(imageSrc.c_str() );
    if (!image.data) {
        return StatusNoImage;
    }
    if (!spectacles.data) {
        return StatusNoSpectacles;
    }
    doThreshold(spectacles, specMask, 150, 255, CV_THRESH_BINARY_INV );
    if (debug) {
        namedWindow("Threshold");
        imshow("Threshold",specMask);
    }

    //convert the image to grayscale
    Mat gray(image.rows, image.cols, CV_8UC1);
    cvtColor(image, gray, CV_BGR2GRAY);
    equalizeHist(gray, gray);

    // detect faces and eyes
    faceCascade.detectMultiScale(gray, faces, 1.1, 2|CV_HAAR_SCALE_IMAGE);
    if (debug) doMarkObjects(faces, face_color);

    eyesCascade.detectMultiScale( gray, objects, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE );
    if (debug) doMarkObjects(objects, eye_color);

    //sort the results from left-to-right
    std::sort(faces.begin(), faces.end(), by_x());
    std::sort(objects.begin(), objects.end(), by_x());

    //iterate over all found faces
    pred_within_rect pwr;
    for ( vector<Rect>::iterator face = faces.begin();face<faces.end();face++)
    {
        //process the detected face: if there are eyes found within it, then put spectacles on it
        pwr.r = (*face);
        vector<Rect>::iterator eye =std::find_if(objects.begin(), objects.end(),pwr);
        if (eye!=objects.end())
        {
            doPutSpectaclesOnFace(*face, eye);
        }
    }
    imshow(title, image);
    return StatusOK;
}
int 
define_subcubes (
    int nsets_real,		/* actual number of sets being created */
    int ndims_tot,		/* total hypercube dimensions */
    int ndims,		/* # dimension in this cut */
    struct set_info *set,		/* data for set being divided */
    struct set_info *set_info,	/* data for all sets */
    int *subsets,		/* subsets to be created */
    int inert,		/* using inertial method? */
    int *pstriping,		/* cut in single direction? */
    int hop_mtx_special[MAXSETS][MAXSETS]	/* nonstandard hop values */
)
{
    extern int KL_METRIC;	/* 2 => using hops so generate hop matrix */
    int       hop_flag;		/* use special hop matrix? */
    int       nsets;		/* number of sets being created */
    int       setnum;		/* global number of subset */
    int       bits;		/* number of bits in which two sets differ */
    int       i, j, k;		/* loop counters */
    int       gray();

    nsets = 1 << ndims;
    hop_flag = FALSE;

    for (k = nsets - 1; k >= 0; k--) {	/* Backwards to not overwrite current set. */

	setnum = set->setnum | (k << (ndims_tot - set->ndims));
	set_info[setnum].ndims = set->ndims - ndims;
	subsets[k] = (int) setnum;
    }

    *pstriping = (inert && nsets_real > 2);

    if (*pstriping) {		/* Gray code for better mapping. */
        for (k = 0; k < nsets; k++) {
	    subsets[k] = (int) gray((int) subsets[k]);
	}

	if (KL_METRIC == 2) {
	    hop_flag = TRUE;
	    for (i = 0; i < nsets; i++) {
		hop_mtx_special[i][i] = 0;
		for (j = 0; j < i; j++) {
		    hop_mtx_special[i][j] = 0;
		    bits = ((int) subsets[i]) ^ ((int) subsets[j]);
		    while (bits) {
			if (bits & 1) {
			    ++hop_mtx_special[i][j];
			}
			bits >>= 1;
		    }
		    hop_mtx_special[j][i] = hop_mtx_special[i][j];
		}
	    }
	}
    }
Example #13
0
 void updateRGB() override {
     float h = qBound(0.0f, hsx(0), 1.0f);
     float s = qBound(0.0f, hsx(1), 1.0f);
     float x = qBound(0.0f, hsx(2), 1.0f);
     
     KisColor::VecRGB gray(x, x, x);
     ::getRGB(rgb(0), rgb(1), rgb(2), h);
     ::setLightness<HSXType>(rgb(0), rgb(1), rgb(2), x);
     rgb = gray + (rgb - gray) * s;
 }
Example #14
0
DisplayNodeQT::DisplayNodeQT(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DisplayNodeQT)
{
    ui->setupUi(this);
    setWindowTitle("Wyświetlenie elementu");

    connect(ui->pushButton, SIGNAL (clicked()), this, SLOT (gray()));
    connect(ui->pushButton_2, SIGNAL (clicked()), this, SLOT (smoothes()));
    connect(ui->pushButton_3, SIGNAL (clicked()), this, SLOT (conture()));
}
Example #15
0
cv::Mat filterMedian(cv::Mat& I) {
	CV_Assert(I.depth() != sizeof(uchar));
	cv::Mat  res(I.rows, I.cols, CV_8UC3);
	unsigned int N = 3;
	unsigned int R = N/2;

	cv::Mat_<cv::Vec3b> _I = I;
	cv::Mat_<cv::Vec3b> _R = res;
	for (unsigned int i = N / 2; i < I.rows - N / 2; i++) {
		for (unsigned int j = N / 2; j < I.cols - N / 2; j++) {
			auto mask = getMask(_I, i, j, N);
			std::sort(mask.begin(), mask.end(), [](const cv::Vec3b &p, const cv::Vec3b &r) {
				return gray(p) < gray(r);
			});
			auto rank_pix = mask[R >= mask.size() ? mask.size() - 1 : R];
			_R(i, j) = rank_pix;
		}
	}
	return res;
}
Example #16
0
int main(int argc, char *argv[])
{
    GL gl;
    ToyouraPNG toyoura;
    ObjectColor red(1.0, 0.0, 0.0);
    ObjectColor blue(0.0, 1.0, 0.0);
    ObjectColor white(1.f, 1.f, 1.f);
    ObjectColor gray(0.5, 0.5, 0.5);
    Math3D::Quaternion quat;
    Math3D::Degree angle(120);
    Math3D::Vector3 pos(0, 0, 1);
    quat.fromAngleAxis(angle, pos);
    GLTexture texture(toyoura);
    pGLSphere   sphere(new GLSphere);
    pGLFloor   floor(new GLFloor);
    sphere -> setColor(red);
    sphere -> setSize(10);
    floor  -> setTexture(texture);
    floor  -> setAttitude(quat);
    floor  -> setSize(100.f, 100.f);
/*
    pCube     cube(new Cube);
    pSphere   sphere(new Sphere);
    pFloor    floor(new Floor);
    pAxis     axis(new Axis);
    pCylinder cylinder(new Cylinder);

    cube-> setSize(5, 5, 5);
    cube-> setPosition(30, 0, 0);

    sphere -> setPosition(0, 10, 0);
    sphere -> setAttitude(quat);


    cylinder -> setColor(blue);
    cylinder -> setAttitude(quat);
    cylinder -> setAttitude(quat);
    cylinder -> setSize(5, 10);

    glfw.pushObject(floor);
    glfw.pushObject(axis);
    glfw.pushObject(cylinder);
    glfw.pushObject(cube);
*/
    gl.pushObject(sphere);
    gl.pushObject(floor);
    gl.setCamera();
    gl.setLight();
    gl.run();

    return 0;
}
Example #17
0
/* detect barcode on the line and try to read it */
int find_barcode(int row,unsigned char *b,int stride) {
	int j,i,w=stride/3-2;
	int blocks=0,sum,line = 0;
	/* there should be at least 100 edges on line */
	int run,min_run = 100;
	int x,x0,x1; /* starting and closing position */

	/* detect edges on the line and count their number */
	for(i=0;i<w;i++) {
		int diff = abs(gray(b,i+1+1) - gray(b,i+1-1));
		if(diff > 20) line++;
		diff_line[i] = diff;
	}
	/* do not continue, if not enough */
	if(line < min_run) return 0;

	/* find starting and closing position */
	for(x0=25;x0<w-25;x0++) if(changes_enough(x0-15,30,10)) break;
	for(x1=w-25;x1>25;x1--) if(changes_enough(x1-15,30,10)) break;

	/* try to read barcode */
	return read_barcode(b,x0-10,x1+10,row);
}
Example #18
0
/* Fixes foreground based on background */
void separate_fg_bg(int *fgr, int *fgg, int *fgb
	, int bgr, int bgg, int bgb)
{
	if (too_near(*fgr, *fgg, *fgb, bgr, bgg, bgb)){
		*fgr=255-bgr;
		*fgg=255-bgg;
		*fgb=255-bgb;
	}else return;
	if (too_near(*fgr, *fgg, *fgb, bgr, bgg, bgb)){
		if (gray(bgr, bgg, bgb)<=1275)
			*fgr=*fgg=*fgb=255;
		else
			*fgr=*fgg=*fgb=0;
	}
}
Example #19
0
TEMPLATE void CDialogMinTrayBtn<BASE>::MinTrayBtnDraw()
{
    if (!MinTrayBtnIsVisible())
       return;

    CDC *pDC= GetWindowDC();
    if (!pDC)
       return; // panic!

    if (IsWindowsClassicStyle())
    {
        CBrush black(GetSysColor(COLOR_BTNTEXT));
        CBrush gray(GetSysColor(COLOR_GRAYTEXT));
        CBrush gray2(GetSysColor(COLOR_BTNHILIGHT));

        // button
        if (m_bMinTrayBtnUp)
           pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH);
        else
           pDC->DrawFrameControl(MinTrayBtnGetRect(), DFC_BUTTON, DFCS_BUTTONPUSH | DFCS_PUSHED);

        // dot
        CRect btn = MinTrayBtnGetRect();
        btn.DeflateRect(2,2);
        UINT caption = MinTrayBtnGetSize().cy + (CAPTION_BUTTONSPACE * 2);
        UINT pixratio = (caption >= 14) ? ((caption >= 20) ? 2 + ((caption - 20) / 8) : 2) : 1;
        UINT pixratio2 = (caption >= 12) ? 1 + (caption - 12) / 8: 0;
        UINT dotwidth = (1 + pixratio * 3) >> 1;
        UINT dotheight = pixratio;
        CRect dot(CPoint(0,0), CPoint(dotwidth, dotheight));
        CSize spc((1 + pixratio2 * 3) >> 1, pixratio2);
        dot -= dot.Size();
        dot += btn.BottomRight();
        dot -= spc;
        if (!m_bMinTrayBtnUp)
           dot += CPoint(1,1);
        if (m_bMinTrayBtnEnabled)
        {
           pDC->FillRect(dot, &black);
        }
        else
        {
           pDC->FillRect(dot + CPoint(1,1), &gray2);
           pDC->FillRect(dot, &gray);
        }
    }
	else
	{
Example #20
0
File: game.cpp Project: erik/blocks
void Game::CreateGame() {
    // Create the scene

    context->scene->Init(context);

    // Create the GUI

    sf::Color gray(0x44, 0x44, 0x44, 128);

    sf::Rect<int> scoreRect(100, 100, 200, 150);

    GUIButton *scoreBut = new GUIButton("SCORE: ", scoreRect, gray, gray);

    gui->AddElement(scoreBut);

}
Example #21
0
 bool ACapture::nextFrame(Mat & frame){
   Mat frm;
   bool hasNext;
   hasNext=extractFrame(frm);
   if (hasNext){
     if (toGrayscale && frm.channels()>2){
       Mat gray(frm.size(), CV_8UC1);
       cvtColor(frm, gray, CV_BGR2GRAY);
       gray.copyTo(frame);
     } else {
       frm.copyTo(frame);
     }
     return true;
   }
   return false;
 }  
Example #22
0
U32 CPictogram::SumMegapixel(int mpx, int mpy, float megapixel_width, float megapixel_height)
{
    if(!corrected) return 0;
    U32 acc = 0;
    Mat gray(image_gray);
    
    for(int i=floor(mpx*megapixel_height);i<floor((mpx+1)*megapixel_height); i++)
    {
        for(int j=floor(mpy*megapixel_width);j<floor((mpy+1)*megapixel_width); j++)
        {
            acc+= gray.at<unsigned char>(i,j);
        }
    }
    
    return acc;
}
Example #23
0
File: main.cpp Project: digirea/KVS
int main( int argc, char** argv )
{
    kvs::glut::Application app( argc, argv );

    PaintEvent paint_event;

    kvs::glut::Screen screen( &app );
    screen.addEvent( &paint_event );
    screen.setTitle( "RadioButton" );
    screen.setGeometry( 0, 0, 512, 512 );
    screen.show();

    kvs::glut::RadioButtonGroup group;

    GrayButton gray( &screen );
    gray.setX( 10 );
    gray.setY( 10 );
    gray.setMargin( 10 );
    gray.setCaption("Gray");
    gray.setState( true );

    RedButton red( &screen );
    red.setX( gray.x() );
    red.setY( gray.y() + 20 );
    red.setMargin( 10 );
    red.setCaption("Red");

    GreenButton green( &screen );
    green.setX( red.x() );
    green.setY( red.y() + 20 );
    green.setMargin( 10 );
    green.setCaption("Green");

    BlueButton blue( &screen );
    blue.setX( green.x() );
    blue.setY( green.y() + 20 );
    blue.setMargin( 10 );
    blue.setCaption("Blue");

    group.add( &gray );  // 0
    group.add( &red );   // 1
    group.add( &green ); // 2
    group.add( &blue );  // 3
    group.show();

    return app.run();
}
Example #24
0
void draw()
{
    background(gray(122));
    while (Soloud_getActiveVoiceCount(soloud) > 0)
    {
        float * v = Soloud_calcFFT(soloud);
        int p = (int)(v[10] * 30);
        if (p > 59) p = 59;
        for (i = 0; i < p; i++)
            printf("=");
        for (i = p; i < 60; i++)
            printf(" ");
        printf("\r");
        printf("%c\r", "|\\-/"[i&3]);
        i++;
    }
}
Example #25
0
/*
* Goes through all the items in the display
* Sets colors based on status
* New - Purple
* Overdue and undone - Red
* The rest alternate between grey and black
*/
void DisplayFeed::setItemColors(){
    QBrush gray(QColor(100, 100, 100));
    for(unsigned int i = 0; i < count(); i++){
        Event* event = dynamic_cast<QEventStore*>(item(i))->getEvent();
        boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
        if(event->isRecent()){
            item(i)->setForeground(Qt::darkMagenta);
            dynamic_cast<QEventStore*>(item(i))->getEvent()->removeRecent();
        }else if((event->getPosixStartTime() < now || event->getPosixEndTime() < now) && !event->getDone()){
            // only undone and overdue tasks to be in red
            item(i)->setForeground(Qt::red);
        }else if(i % 2 == 1){
            item(i)->setForeground(gray);
        }else{
            item(i)->setForeground(Qt::black);
        }
    }
}
Example #26
0
void Viewer::saveImage(const colorspaces::Image& imageColor)
{


	IceUtil::Time currentTime = IceUtil::Time::now();
	if ((currentTime - lastTimePhoto).toSeconds() == delayPhoto)
	{

		// Check the directory
		if ( !boost::filesystem::exists(pathImage))
		{
			boost::filesystem::path dir(pathImage);
			if (!boost::filesystem::create_directory(dir))
				std::cout << "Error to create directory" << std::endl;

		}


		lastTimePhoto = IceUtil::Time::now();

		// Convert to gray
		Mat gray(imageColor.size(), CV_8UC1);
		cvtColor(imageColor, gray, CV_RGB2GRAY);

		// Save Image
		std::stringstream filename;
		filename << pathImage << "img" << contPhoto << ".jpg";
		imwrite( filename.str().c_str(), gray );

		std::string msg = "Image saved: " + filename.str();
		tvStatus->get_buffer()->set_text(msg.c_str());

		beep();

		if (contPhoto < numPhoto)
			contPhoto ++;
		else
		{
			intrinsicsEnable = 0;
			contPhoto = 1;
		}
	}

}
Example #27
0
void draw()
{
    background(gray(122));

    if (mousePressed)
    {
        image(img1, mouseX, mouseY, img1.width, img1.height);
    }
    else
    {
        image(img2, mouseX, mouseY, img2.width, img2.height);
    }

    textFont(font);
    textAlign(NVG_ALIGN_CENTER);
    textSize(30);
    textLeading(5);
    text("test everything here", width/2, height/2);
}
cv::Mat detectFace(cv::Mat frame) {
	cv::Mat gray(frame.size(), CV_8UC1);
	cv::cvtColor(frame, gray, cv::COLOR_BGR2GRAY); //Not needed, detectMultiScale takes care of conversion of conversion to grayscale.

	std::vector<cv::Rect> faceDetected;
	faceDetector.detectMultiScale(gray, faceDetected, scaleFactor, 0, flags, minFaceSize);
	
	std::vector<int> numDetections;
	cv::groupRectangles(faceDetected, numDetections, minNeighbors, GROUP_EPS);

	for (unsigned int i = 0; i < faceDetected.size(); i++) {
		cv::Rect rect = faceDetected.at(i);
		cv::rectangle(frame, rect, cv::Scalar(0, 0, 255), 1);
		cv::putText(frame, std::to_string(numDetections[i]),
			cv::Point(rect.x, rect.y), 1, 1, cv::Scalar(0, 0, 255));
	}

	return frame;
}
Example #29
0
 system::error_code PoseTracker::track(intrusive_ptr<base::PixelSampleBuffer> psb)
 {
     if(!m_bPrepared)
         return base::makeErrorCode(base::kENotStarted);
     
     Vec2i bfferSize = psb->planeSize();
     
     ::cv::Mat gray(
         bfferSize[1],
         bfferSize[0],
         CV_8UC1,
         psb->planeData(),
         psb->planeRowBytes()
     );
     
     const double ts = chrono::duration_cast<chrono::nanoseconds>(psb->time.time_since_epoch()).count()*1.0e-9;
     m_SVOFrameHandler->addImage(gray, ts);
     
     return base::makeErrorCode(base::kENoError);
 }
Example #30
0
inline int ReadImage(const char * path, Image<RGBColor> * im)
{
  std::vector<unsigned char> ptr;
  int w, h, depth;

  int res = ReadImage(path, &ptr, &w, &h, &depth);

  if (res == 1) {
    if(depth == 3)
    {
      (*im) = Image<RGBColor>(w, h, (const RGBColor*) &ptr[0]);
    } else if(depth == 1)
    {
      Image<unsigned char> gray(w, h, &ptr[0]);
      convertImage(gray, im);
    } else
      res = 0; // Do not know how to convert to color
  }
  return res;
}