예제 #1
0
        void button::draw()
        {
            color old_fg = get_foreground();
            color old_bg = get_background();

            if (down_tick)
            {
                if ((SDL_GetTicks() - down_tick) < 100)
                {
                    get_foreground() = old_bg;
                    get_background() = old_fg;
                }
                else
                {
                    down_tick = 0;
                }
            }

            textbox::draw();

            // border
            display::scoped_color fg(get_screen(), get_foreground());
            get_screen().draw_line_2d(0, 0, get_w(), 0);
            get_screen().draw_line_2d(get_w(), 0, get_w(), get_h());
            get_screen().draw_line_2d(get_w(), get_h(), 0, get_h());
            get_screen().draw_line_2d(0, get_h(), 0, 0);

            if (down_tick)
            {
                get_foreground() = old_fg;
                get_background() = old_bg;
            }
        } // button::draw()
예제 #2
0
void xbm_start(struct cached_image *cimg)
{
    struct xbm_decoder *deco;
    unsigned short r,g,b;

    deco=mem_alloc(sizeof(struct xbm_decoder));
    cimg->decoder=deco;
    deco->state=0;
    deco->width=-1;
    deco->height=-1;
    deco->buffer_pos=0;
    deco->partnum=0;
    deco->in_data_block=0;

    round_color_sRGB_to_48(&r,&g,&b,cimg->background_color);
    deco->barvicky[0]=apply_gamma_single_16_to_8(r,display_red_gamma);
    deco->barvicky[1]=apply_gamma_single_16_to_8(g,display_green_gamma);
    deco->barvicky[2]=apply_gamma_single_16_to_8(b,display_blue_gamma);

    round_color_sRGB_to_48(&r,&g,&b,get_foreground(cimg->background_color));
    deco->barvicky[3]=apply_gamma_single_16_to_8(r,display_red_gamma);
    deco->barvicky[4]=apply_gamma_single_16_to_8(g,display_green_gamma);
    deco->barvicky[5]=apply_gamma_single_16_to_8(b,display_blue_gamma);


}
예제 #3
0
int vehicle_det::do_iteration()
{
    //cout<<__PRETTY_FUNCTION__<<endl;
    cv::Mat img_input, src;
    cap >> src;

    if(!src.data)
    {
        printf("Exiting\n");
        return -1;
    }

    Mat img_display = src.clone();
    draw_ROI_poly(img_display);
    src.copyTo(img_input, mask);
    img_input = Mat(img_input, main_roi);
    IplImage temp = img_input;
    IplImage * frame = &temp;
    //getting the polygon
    // bgs->process(...) internally process and show the foreground mask image
    cv::Mat img_mask;
    //bgs->process(img_input, img_mask);
    get_foreground(img_input, img_mask);
    blur(img_mask, img_mask, Size(4, 4));
    img_mask = img_mask > 10;
    /*morphologyEx(img_mask, img_mask, MORPH_CLOSE, Mat(25, 2, CV_8U));
    morphologyEx(img_mask, img_mask, MORPH_OPEN, Mat(10, 10, CV_8U));*/
    morphologyEx(img_mask, img_mask, MORPH_CLOSE, Mat(2, 2, CV_8U));
    //morphologyEx(img_mask, img_mask, MORPH_OPEN, Mat(10, 10, CV_8U));
    //morphologyEx(img_mask, img_mask, MORPH_GRADIENT , Mat(5,5, CV_8U));
    //bgs->operator()(img_input,img_mask,0.2);
    //erode(img_mask, img_mask, Mat());
    //dilate(img_mask, img_mask, Mat());
    //imshow("fore", img_mask);

    if(!img_mask.empty())
    {
        //vector<Rect> rois;// to be added all the ROIs
        IplImage copy = img_mask;
        IplImage * new_mask = &copy;
        IplImage * labelImg = cvCreateImage(cvGetSize(new_mask), IPL_DEPTH_LABEL, 1);
        CvBlobs blobs, filtered_blobs;
        unsigned int result = cvb::cvLabel(new_mask, labelImg, blobs);
        cvFilterByArea(blobs, 40, 2000);
        int count = 0;

        for(CvBlobs::const_iterator it = blobs.begin(); it != blobs.end(); ++it)
        {
            count++;
            //  cout << "Blob #" << it->second->label << ": Area=" << it->second->area << ", Centroid=(" << it->second->centroid.x << ", " << it->second->centroid.y << ")" << endl;
            int x, y;
            x = (int)it->second->centroid.x;
            y = (int)it->second->centroid.y;
            //cv::Point2f p(x,y );
            // circle(img_input, p, (int)10, cv::Scalar(255, 0 , 0), 2, 8, 0);
            int x_final = 0;
            int y_final = 0;

            if(x - (width_roi / 2) <= 0)
            {
                x_final = 1;
            }
            else if(x + (width_roi / 2) >= img_input.cols)
            {
                x_final = (x - (width_roi / 2)) - (x + (width_roi / 2) - (img_input.cols - 1));
            }
            else
            {
                x_final = x - (width_roi / 2);
            }

            if(y - (height_roi / 2) <= 0)
            {
                y_final = 1;
            }
            else if(y + (height_roi / 2) >= img_input.rows)
            {
                y_final = (y - (height_roi / 2)) - (y + (height_roi / 2) - (img_input.rows - 1));
            }
            else
            {
                y_final = y - (height_roi / 2);
            }

            //printf("resized x_final=%d y_final=%d  cols=%d,  rows=%d \n", x_final,y_final,img_input.cols,img_input.rows);
            Rect roi(x_final, y_final, width_roi, height_roi);
            //rois.push_back(roi);//adding ROIs using rectangles
            //		Mat image = imread("");
            Mat image_roi = Mat(img_input, roi);
            int vehicle_ct = detect(image_roi); //getting the vehicle count per ROI

            if(vehicle_ct > 0)
            {
                filtered_blobs[it->first] = it->second;
                int matched = 0;
                int c1 = 255, c2 = 0;

                if(matched)
                {
                    c1 = 0;
                    c2 = 255;
                }
                else
                {
                    //print something to debug
                }//changing the colour of  the rectanged depending on matched or not matched

                rectangle(img_display,
                          Point(min_x + x - 5, min_y + y - 5),
                          Point(min_x + x + 5, min_y + y + 5),
                          CV_RGB(c1, c2, 0), 2, 8, 0);
                /*rectangle(img_input,
                          Point(x - 5, y - 5),
                          Point(x + 5, y + 5),
                          CV_RGB(c1, c2, 0), 2, 8, 0);*/
            }
        }

        //cvUpdateTracks(filtered_blobs, tracks, 5., 10);
        cvUpdateTracks(filtered_blobs, tracks, 10., 5);
        cvRenderBlobs(labelImg, filtered_blobs, frame, frame, CV_BLOB_RENDER_CENTROID | CV_BLOB_RENDER_BOUNDING_BOX);
        //cvRenderTracks(tracks, frame, frame, CV_TRACK_RENDER_ID|CV_TRACK_RENDER_BOUNDING_BOX|CV_TRACK_RENDER_TO_LOG);
        cvRenderTracks(tracks, frame, frame, CV_TRACK_RENDER_ID);
        printf("num of active tracks %d\n", tracks.size());
        process_equation(tracks.size());//number of people given as input
	if(abstract_det::Total_Score<0){
		destroyAllWindows();	
	}
    }

    if(!img_display.empty())
    {
        cv::imshow("vehicle_view", img_display);
    }

    waitKey(30);
    
    return 1;
}
예제 #4
0
void colour_pair::set_background(short background) {
	colour_pair tmp { get_foreground(), background };
	swap(tmp);
}