Ejemplo n.º 1
0
void
test (void)
{
  int i, j, *res = correct_results;

  for (i = 0; i < 8; i++)
    {
      float arg0 = args[i];
      for (j = 0; j < 8; j++)
	{
	  float arg1 = args[j];

	  if (feq (arg0, arg1) != *res++)
	    abort ();
	  if (fne (arg0, arg1) != *res++)
	    abort ();
	  if (flt (arg0, arg1) != *res++)
	    abort ();
	  if (fge (arg0, arg1) != *res++)
	    abort ();
	  if (fgt (arg0, arg1) != *res++)
	    abort ();
	  if (fle (arg0, arg1) != *res++)
	    abort ();
	}
    }
}
Ejemplo n.º 2
0
void diffuse_vector(TriMesh *themesh, std::vector<T> &field, float sigma)
{
	themesh->need_normals();
	themesh->need_pointareas();
	themesh->need_neighbors();
	int nv = themesh->vertices.size();

	dprintf("\rSmoothing vector field... ");
	timestamp t = now();

	float invsigma2 = 1.0f / sqr(sigma);

	vector<T> flt(nv);
	AccumVec<T> a(field);
#pragma omp parallel
	{
		// Thread-local flags
		vector<unsigned> flags(nv);
		unsigned flag_curr = 0;

#pragma omp for
		for (int i = 0; i < nv; i++)
			diffuse_vert_field(themesh, flags, flag_curr,
				a, i, invsigma2, flt[i]);
	} // #pragma omp parallel

	field = flt;

	dprintf("Done.  Filtering took %f sec.\n", now() - t);
}
Ejemplo n.º 3
0
int main(int argc, char *args[])
{
	g=argc;
	dec(argc);
	hex(argc);
	flt(argc);
	oct(argc);
	return 0;
}
Ejemplo n.º 4
0
    /**
     * @brief test
     */
    static void test()
    {
        Image img(1, 512, 512, 3);
        img = 1.0f;

        FilterCrop flt(Vec2i(100, 100), Vec2i(200, 200));

        Image *out = flt.Process(Single(&img), NULL);

        out->Write("test_crop_2d_output.pfm");
    }
Ejemplo n.º 5
0
    /**
     * @brief RGBtoLogLuv
     * @param imgIn
     * @param imgOut
     * @param bDirect
     * @return
     */
    static Image *RGBtoLogLuv(Image *imgIn, Image *imgOut,
                                        bool bDirect)
    {
        ColorConvRGBtoXYZ       csXYZ;
        ColorConvXYZtoLogLuv    csLogLuv;

        FilterColorConv flt(NULL, bDirect);

        flt.insertColorConv(&csXYZ);
        flt.insertColorConv(&csLogLuv);

        return flt.Process(Single(imgIn), imgOut);
    }
Ejemplo n.º 6
0
    /**
     * @brief ExectueCIELABtoRGB
     * @param imgIn
     * @param imgOut
     * @param bDirect
     * @return
     */
    static Image *CIELABtoRGB(Image *imgIn, Image *imgOut,
                                        bool bDirect)
    {
        ColorConvRGBtoXYZ       csXYZ;
        ColorConvXYZtoCIELAB    csCIELAB;

        FilterColorConv flt(NULL, bDirect);

        flt.insertColorConv(&csCIELAB);
        flt.insertColorConv(&csXYZ);

        return flt.Process(Single(imgIn), imgOut);
    }
Ejemplo n.º 7
0
int main(int argc,char **argv)
{
	std::string captured;
	try {
		cppcms::service srv(argc,argv);
		write_tests = srv.settings().get("test.write",false);
		booster::intrusive_ptr<cppcms::application> async = new async_test(srv);
		srv.applications_pool().mount( async, cppcms::mount_point("/async") );
		srv.applications_pool().mount( cppcms::applications_factory<sync_test>(), cppcms::mount_point("/sync"));
		srv.after_fork(submitter(srv));
		cppcms::copy_filter flt(std::cerr); // record the log
		srv.run();
		captured = flt.detach(); // get the log
	}
	catch(std::exception const &e) {
		std::cerr << e.what() << std::endl;
		return EXIT_FAILURE;
	}
	size_t pos = 0;
	while((pos=captured.find("Timeout on connection",pos))!=std::string::npos) {
		pos+=10;
		count_timeouts++;
	}
	if(
		write_tests ?
		(
			async_bad_count != 2 
			|| sync_bad_count != 2 
			|| count_timeouts != 4
			|| above_15 != 2
			|| below_10 != 2
		)
		:
		(
			!eof_detected 
			|| count_timeouts != 5
		)
	  ) 
	{
		print_count_report(std::cerr);
		std::cerr << "Failed" << std::endl;
		return EXIT_FAILURE;
	}
	print_count_report(std::cout);
	if(!run_ok ) {
		std::cerr << "Python script failed" << std::endl;
		return EXIT_FAILURE;
	}
	std::cout << "Ok" << std::endl;
	return EXIT_SUCCESS;
}
Ejemplo n.º 8
0
 void CheckGetSized(int destsize,
                    int valsize,
                    int correct_retval,
                    const unsigned char* correct_result)
 {
     llvm::APFloat flt(llvm::APFloat::x87DoubleExtended, GetParam().ascii);
     yasm::Bytes result;
     result.resize(destsize);
     result.setLittleEndian();
     yasm::NumericOutput num_out(result);
     num_out.setSize(valsize);
     num_out.OutputFloat(flt);
     for (int i=0; i<destsize; ++i)
         EXPECT_EQ(correct_result[i], result[i]);
 }
HRESULT GetFilter_old(dimension_t dimension, short index, BSTR* filter)
{
    std::string  szFG;
    std::string  szFV;
    int  newIndex  = offset_to_new_index_(atFilter, dimension, index);

    XXGetFilterEx_(dimension, newIndex, &szFG, &szFV);

    CString flt(szFG.c_str());  // +1
    flt += strFilterSeparator;  // +2
    flt += szFV.c_str();        // +1

    CComBSTR bFilter(flt);      // +1

    *filter = bFilter.Detach();

    return S_OK;
}
Ejemplo n.º 10
0
/*==============================================================================
 * FUNCTION:        DfaTest::testMeetSize
 * OVERVIEW:        Test meeting IntegerTypes with various other types
 *============================================================================*/
void DfaTest::testMeetSize()
{
    IntegerType i32(32, 1);
    SizeType s32(32);
    SizeType s16(16);
    FloatType flt(32);
    VoidType v;

    bool ch = false;
    Type *res = s32.meetWith(&i32, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost1;
    ost1 << res;
    std::string actual(ost1.str());
    std::string expected("i32");
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ch = false;
    res = s32.meetWith(&s16, ch, false);
    CPPUNIT_ASSERT(ch == false);

#if 0
    // There is a known failure here; to show the warning, use ErrLogger
    Boomerang::get()->setLogger(new ErrLogger);

    res = s16.meetWith(&flt, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost2;
    ost2 << res;
    actual = ost2.str();
    expected = "union";
    CPPUNIT_ASSERT_EQUAL(expected, actual);
#endif

    ch = false;
    res = s16.meetWith(&v, ch, false);
    CPPUNIT_ASSERT(ch == false);
    std::ostringstream ost3;
    ost3 << res;
    actual = ost3.str();
    expected = "16";
    CPPUNIT_ASSERT_EQUAL(expected, actual);
}
Ejemplo n.º 11
0
/*==============================================================================
 * FUNCTION:        DfaTest::testMeetUnion
 * OVERVIEW:        Test meeting IntegerTypes with various other types
 *============================================================================*/
void DfaTest::testMeetUnion()
{
    UnionType u1;
    IntegerType i32(32, 1);
    IntegerType j32(32, 0);
    IntegerType u32(32, -1);
    FloatType flt(32);
    u1.addType(&i32, "bow");
    u1.addType(&flt, "wow");

    std::ostringstream ost1;
    ost1 << u1.getCtype();
    std::string actual(ost1.str());
    std::string expected("union { int bow; float wow; }");
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    bool ch = false;
    Type *res = u1.meetWith(&j32, ch, false);
    CPPUNIT_ASSERT(ch == false);
    std::ostringstream ost2;
    ost2 << res->getCtype();
    actual = ost2.str();
    expected = "union { int bow; float wow; }";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    res = u1.meetWith(&j32, ch, false);
    CPPUNIT_ASSERT(ch == false);
    std::ostringstream ost3;
    ost3 << u1.getCtype();
    actual = ost3.str();
    expected = "union { int bow; float wow; }";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    // Note: this test relies on the int in the union having signedness 1
    res = u1.meetWith(&u32, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost4;
    ost4 << u1.getCtype();
    actual = ost4.str();
    expected = "union { /*signed?*/int bow; float wow; }";
    CPPUNIT_ASSERT_EQUAL(expected, actual);
}
Ejemplo n.º 12
0
ConvLayer::ConvLayer(int filters, ivec inshape, ivec fshape, int stride,
                     ConvNet* net)
{
    InShape  = inshape;
    Stride   = stride;
    Fshape   = fshape;
    OutShape = outshape(InShape, Fshape, Stride, filters);
    Steps    = calcsteps(InShape, Fshape, Stride, filters);
            
    dmatrix3 refE(OutShape[0], dmatrix2(OutShape[1], dvec(OutShape[2], 0.0)));
    refE.swap(Excitations);
    dmatrix3 refA(OutShape[0], dmatrix2(OutShape[1], dvec(OutShape[2], 0.0)));
    refA.swap(Activations);
    dmatrix3 refErr(OutShape[0],dmatrix2(OutShape[1],dvec(OutShape[2], 0.0)));
    refErr.swap(Errors);
    dmatrix4 flt(filters,dmatrix3(InShape[0],
                 dmatrix2(Fshape[0],dvec(Fshape[1], 0.5))));
    flt.swap(Filters);
    
    Brain = net;
}
Ejemplo n.º 13
0
WEXPORT WFileDialog::WFileDialog( WWindow* parent, unsigned res_idx )
        : _parent( parent ) {
/***************************/

    static char     buffer[ 512 ];
    WResStr         flt( res_idx );
    const char *    filter;
    unsigned        i = 0;

    filter = flt;

    do {
        if( filter[i] == REPCHAR ) {
            buffer[ i ] = '\0';
        } else {
            buffer[ i ] = filter[ i ];
        }
    } while( filter[ i++ ] );

    _fileName = new char[ WFileBufSize ];
    makeDialog( buffer );
}
Ejemplo n.º 14
0
void KateFileSelector::readConfig(TDEConfig *config, const TQString & name)
{
  dir->setViewConfig( config, name + ":view" );
  dir->readConfig(config, name + ":dir");
  dir->setView( KFile::Default );
  dir->view()->setSelectionMode(KFile::Extended);
  config->setGroup( name );

  // set up the toolbar
  setupToolbar( config );

  cmbPath->setMaxItems( config->readNumEntry( "pathcombo history len", 9 ) );
  cmbPath->setURLs( config->readPathListEntry( "dir history" ) );
  // if we restore history
  if ( config->readBoolEntry( "restore location", true ) || kapp->isRestored() ) {
    TQString loc( config->readPathEntry( "location" ) );
    if ( ! loc.isEmpty() ) {
//       waitingDir = loc;
//       TQTimer::singleShot(0, this, TQT_SLOT(initialDirChangeHack()));
      setDir( loc );
    }
  }

  // else is automatic, as cmpPath->setURL is called when a location is entered.

  filter->setMaxCount( config->readNumEntry( "filter history len", 9 ) );
  filter->setHistoryItems( config->readListEntry("filter history"), true );
  lastFilter = config->readEntry( "last filter" );
  TQString flt("");
  if ( config->readBoolEntry( "restore last filter", true ) || kapp->isRestored() )
    flt = config->readEntry("current filter");
  filter->lineEdit()->setText( flt );
  slotFilterChange( flt );

  autoSyncEvents = config->readNumEntry( "AutoSyncEvents", 0 );
}
    /**
     * @brief execute
     * @param img
     * @param corners
     */
    void execute(Image *img, std::vector< Eigen::Vector2f > *corners)
    {
        if(img == NULL || corners == NULL) {
            return;
        }

        if(img->channels == 1) {
            bLum = false;
            lum = img;
        } else {
            bLum = true;
            lum = FilterLuminance::execute(img, lum, LT_CIE_LUMINANCE);
        }

        corners->clear();

        std::vector< Eigen::Vector3f > corners_w_quality;

        //filter the input image
        FilterGaussian2D flt(sigma);
        lum_flt = flt.Process(Single(lum), NULL);

        //"rasterizing" a circle
        std::vector< int > x, y;
        int radius_sq = radius * radius;
        for(int i=-radius; i<=radius; i++) {
            int i_sq = i * i;
            for(int j=-radius; j<=radius; j++) {

                if((j == 0) && (i == 0)) {
                    continue;
                }

                int r_sq = i_sq + j * j;
                if(r_sq <= radius_sq){
                    x.push_back(j);
                    y.push_back(i);
                }
            }
        }

        int width  = lum_flt->width;
        int height = lum_flt->height;

        float C = float(x.size());

        float t = 0.05f; //depends on image noise

        float g = C * 0.5f; //geometric constant for determing corners

        Image R(1,width, height, 1);
        R.setZero();
        for(int i = radius; i < (height - radius - 1); i++) {
            for(int j = radius; j < (width - radius - 1); j++) {

                int ind = i * width + j;

                float sum = 0.0f;

                for(unsigned int k = 0; k < x.size(); k++) {
                    int ind_c = (i + y[k]) * width + (j + x[k]);

                    float diff = (lum_flt->data[ind_c] - lum_flt->data[ind]) / t;
                    float diff_2 = diff * diff;
                    float diff_4 = diff_2 * diff_2;
                    float diff_6 = diff_4 * diff_2;

                    sum += expf(-diff_6);
                }

                if(sum < g) {
                    R.data[ind] = g - sum;
                }
            }
        }

        //non-maximal supression
        int side = radius_maxima * 2 + 1;
        int *indices = new int [side * side];

        for(int i = radius_maxima; i< (height - radius_maxima - 1); i++) {

            int tmp = i * width;

            for(int j = radius_maxima; j < (width - radius_maxima - 1); j++) {
                int ind = tmp + j;

                if(R.data[ind] <= 0.0f) {
                    continue;
                }

                indices[0] = ind;
                int counter = 1;

                for(int k = -radius_maxima; k <= radius_maxima; k++) {
                    int yy = CLAMP(i + k, height);

                    for(int l = -radius_maxima; l <= radius_maxima; l++) {

                        if((l == 0) && (k == 0)) {
                            continue;
                        }

                        int xx = CLAMP(j + l, width);

                        ind = yy * width + xx;

                        if(R.data[ind]>0.0f){
                            indices[counter] = ind;
                            counter++;
                        }

                    }
                }

                //are other corners near-by?
                if(counter > 1) {
                    //find the maximum value
                    float R_value = R.data[indices[0]];
                    int index = 0;

                    for(int k = 1; k < counter; k++){
                        if(R.data[indices[k]] > R_value) {
                            R_value = R.data[indices[k]];
                            index = k;
                        }
                    }

                    if(index == 0){
                        corners_w_quality.push_back(Eigen::Vector3f (float(j), float(i), 1.0f) );
                    }
                } else {
                    corners_w_quality.push_back(Eigen::Vector3f (float(j), float(i), 1.0f) );
                }
            }
        }

        sortCornersAndTransfer(&corners_w_quality, corners);

        if(indices != NULL) {
            delete[] indices;
            indices = NULL;
        }
    }
Ejemplo n.º 16
0
// Returns a random float between min and max,
// default parameters are FLT_MIN and FLT_MAX
float RNG::randFloat(float min, float max){
	rnd = std::default_random_engine(rd());
	std::uniform_real_distribution<float> flt(min,max);
	return flt(rnd);
};
Ejemplo n.º 17
0
int main(int argc, char *argv[])
{
    std::string img_str;

    if(argc == 2) {
        img_str = argv[1];
    } else {
        img_str = "../data/input/tommaseo_statue.png";
    }

    printf("Reading an image...");
    pic::Image img;
    img.Read(img_str, pic::LT_NOR_GAMMA);
    printf("Ok\n");

    printf("Is it valid? ");
    if(img.isValid()) {
        printf("Ok\n");

        printf("Estimated noise:\n");
        float *noise = pic::FilterNoiseEstimation::getNoiseEstimation(&img, NULL);
        for(int i = 0; i < img.channels; i++) {
            printf("Channel i-th: %f\n", noise[i]);
        }

        pic::ImageVec input = pic::Single(&img);
        pic::Image *output = NULL;

        bool bWritten;

        std::string name = pic::removeExtension(img_str);
        name = pic::removeLocalPath(name);

        //the bilateral filter
        printf("Filtering the image with a Fast Bilateral filter;\n");
        printf("this has sigma_s = 4.0 and sigma_r = 0.05 ... ");

        pic::FilterBilateral2DS flt(8.0f, 0.05f);
        output = flt.Process(input, output);

        //output = pic::FilterBilateral2DAS::execute(&img, output, 8.0f, 0.05f);

        printf("Ok!\n");

        printf("Writing the file to disk...");

        bWritten = output->Write("../data/output/" + name + "_filtered_bilateral.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }

        //the median filter
        printf("Filtering the image with the Median filter (radius of 3);\n");

        pic::FilterMed fltM(7);
        output = fltM.Process(input, output);

        printf("Ok!\n");

        printf("Writing the file to disk...");

        bWritten = output->Write("../data/output/" + name + "_filtered_median.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }

        //the vector median filter
        printf("Filtering the image with the Vector Median filter (radius of 3);\n");

        pic::FilterMedVec fltMV(7);
        output = fltMV.Process(input, output);

        printf("Ok!\n");

        printf("Writing the file to disk...");

        bWritten = output->Write("../data/output/" + name + "filtered_median_vec.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }

        //the non-local means filter
        printf("Filtering the image with Non-Local Means filter;\n");

        pic::FilterNonLocalMeansF fltNLM(31, 5, 0.05f);
        output = fltNLM.Process(input, output);

        printf("Ok!\n");

        printf("Writing the file to disk...");

        bWritten = output->Write("../data/output/" + name + "_filtered_non_local_means.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }


        //the Anisotropic Diffusion
        printf("Filtering the image with the Anisotropic Diffusion;\n");
        printf("this has sigma_s = 4.0 and sigma_r = 0.05 ... ");
        output = pic::FilterAnsiotropicDiffusion::execute(input, output, 8.0f, 0.05f);
        printf("Ok!\n");

        printf("Writing the file to disk...");
        bWritten = output->Write("../data/output/" + name + "_filtered_anisotropic_diffusion.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }

        //the Guided Filter
        printf("Filtering the image with the Guided filter...");
        pic::FilterGuided fltG;
        output = fltG.Process(input, output);//filtering the image

        printf("Writing the file to disk...");
        bWritten = output->Write("../data/output/" + name + "_filtered_guided.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }

        //WLS
        printf("Filtering the image with the WLS filter...");
        pic::FilterWLS fltWLS;//creating the filter
        output = fltWLS.Process(input, output);
        printf("Ok!\n");

        printf("Writing the file to disk...");
        bWritten = output->Write("../data/output/" + name + "_filtered_wls.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }

        //Kuwahara
        printf("Filtering the image with the Kuwahara filter...");
        pic::FilterKuwahara fltK(11);
        output = fltK.Process(input, output);

        printf("Writing the file to disk...");
        bWritten = output->Write("../data/output/" + name + "filtered_kuwahara.png", pic::LT_NOR_GAMMA);

        if(bWritten) {
            printf("Ok\n");
        } else {
            printf("Writing had some issues!\n");
        }

    } else {
        printf("No it is not a valid file!\n");
    }
}
Ejemplo n.º 18
0
bool
fltAdapter (float a,float b)
{
  return flt (f2i (a),f2i (b));  
}
Ejemplo n.º 19
0
int main(int argc, char **argv)
{
    cv::Mat ms,md;
    cv::Mat cleared, cannyed;
    cv::Mat flt(1, 3, 4);

    // out names
    char clear_noise_tpl[100] = SRCDIR "/%s.clear_noise.bmp";
    char canny_tpl[100] = SRCDIR "/%s.canny.bmp";
    char split_tpls[][100] = {
        SPODIR "/%s.split1.bmp",
        SPODIR "/%s.split2.bmp",
        SPODIR "/%s.split3.bmp",
        SPODIR "/%s.split4.bmp",
        SPODIR "/%s.split5.bmp"
    };
    char buff[100] = {0};

    const char *src_path = argc >= 2 ? argv[1] : DEFALT_SRC;
    const char *fname_start = strrchr(src_path, '/');
    if (fname_start == NULL) fname_start = src_path;
    else fname_start = fname_start + 1;

    // read src
    ms = cv::imread(src_path);

    // 转灰
    cv::cvtColor(ms, md, CV_BGR2GRAY, 1);
    // cv::blur(md, ms, cv::Size(5, 5));
    // cv::bilateralFilter(md, md2, 9, 260, 260);
    // cv::GaussianBlur(md, md2, cv::Size(5, 5), 60);
    // cv::sepFilter2D(md, md2, -1, flt, flt);
    // cv::erode(md, md2, cv::Mat(), cv::Point(-1, -1), 2);
    // cv::dilate(md2, md, cv::Mat(), cv::Point(-1, -1), 2);
    // cv::fastNlMeansDenoising(md, md2, 20);

    cv::imwrite("gray.bmp", md);
    md = detect_background(md);
    cleared = md.clone();
    memset(buff, 0, sizeof(buff));
    sprintf(buff, clear_noise_tpl, fname_start);
    cv::imwrite(buff, cleared);

    // 反转
    for (int i = 0; i < md.rows; i ++) {
        for (int j = 0; j < md.cols; j ++) {
            if ((short)md.at<uchar>(i, j) == 0) {
                md.at<uchar>(i, j) = 255;
            } else {
                md.at<uchar>(i, j) = 0;
            }
        }
    }


    cv::Canny(md, cannyed, 50, 200, 3);
    memset(buff, 0, sizeof(buff));
    sprintf(buff, canny_tpl, fname_start);
    cv::imwrite(buff, cannyed);

    md = cannyed.clone();
    std::vector<std::vector<cv::Point> > contours, sorted_contours;
    std::vector<cv::Vec4i> hia;
    cv::findContours(md, contours, hia, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);
    // 好像这个连接区域检测效果很差啊

    std::cout<< "\n" << contours.size() << "\n";
    for (int i = 0; i < contours.size(); i ++) {
        std::vector<cv::Point> c1 = contours.at(i);
        std::cout<< "" << c1.size() << "," << hia[i] << "\n";        

        for (int j = 0; j < contours.at(i).size(); j++) {
            // std::cout << contours.at(i).at(j) << std::endl;
            md.at<uchar>(contours.at(i).at(j)) = 255;
        }
    }

    /*
    int nc = 7;
    std::vector<std::vector<cv::Point> > ct;
    ct.push_back(contours.at(nc));

    cv::RotatedRect area = cv::minAreaRect(contours.at(nc));
    std::cout<<area.angle<<std::endl;
    area.size = cv::Size(area.size.width + 1, area.size.height + 2);

    cv::Mat mask = cv::Mat::zeros(ms.rows, ms.cols, CV_8UC1);
    cv::drawContours(mask, ct, -1, cv::Scalar(255), CV_FILLED);

    cv::Rect drect = area.boundingRect();
    cv::rectangle(mask, drect, cv::Scalar(255, 0, 0), 2);

    cv::Mat chimg = getRotatedImage(nobg, area);
    */

    // sort
    sorted_contours = sort_contours(contours, SPICNT);

    std::cout<< "\n" << sorted_contours.size() << "\n";
    for (int i = 0; i < sorted_contours.size(); i ++) {
        std::vector<cv::Point> c1 = sorted_contours.at(i);
        std::cout<< "sorted: " << c1.size() << ", " << hia[i] << "\n";        
    }

    for (int i = 0; i < sorted_contours.size(); i ++) {
        cv::RotatedRect area = cv::minAreaRect(sorted_contours.at(i));
        area.size = cv::Size(area.size.width + 1, area.size.height + 2);
        cv::Mat chimg = getRotatedImage(cleared, area);

        memset(buff, 0, sizeof(buff));
        sprintf(buff, split_tpls[i], fname_start);

        std::cout<<buff<<std::endl;
        cv::imwrite(buff, chimg);
    }

    cv::imwrite("graymy.bmp", md);

    return 0;
}
Ejemplo n.º 20
0
/*==============================================================================
 * FUNCTION:        DfaTest::testMeetInt
 * OVERVIEW:        Test meeting IntegerTypes with various other types
 *============================================================================*/
void DfaTest::testMeetInt()
{
    IntegerType i32(32, 1);
    IntegerType j32(32, 0);
    IntegerType u32(32, -1);
    IntegerType xint(0);
    IntegerType j16(16, 0);
    SizeType s32(32);
    SizeType s64(64);
    FloatType flt(32);
    PointerType pt(&flt);
    VoidType v;

    bool ch = false;
    i32.meetWith(&i32, ch, false);
    CPPUNIT_ASSERT(ch == false);
    std::ostringstream ost1;
    ost1 << &i32;
    std::string actual(ost1.str());
    std::string expected("i32");
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    i32.meetWith(&j32, ch, false);
    CPPUNIT_ASSERT(ch == false);
    j32.meetWith(&i32, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost2;
    ost2 << &i32;
    actual = ost2.str();
    expected = "i32";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ch = false;
    j32.setSigned(0);
    j32.meetWith(&v, ch, false);
    CPPUNIT_ASSERT(ch == false);
    std::ostringstream ost2a;
    ost2a << &j32;
    actual = ost2a.str();
    expected = "j32";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ch = false;
    j32.meetWith(&u32, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost3;
    ost3 << &j32;
    actual = ost3.str();
    expected = "u32";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ch = false;
    u32.meetWith(&s32, ch, false);
    CPPUNIT_ASSERT(ch == false);
    std::ostringstream ost4;
    ost4 << &u32;
    actual = ost4.str();
    expected = "u32";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    u32.meetWith(&s64, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost5;
    ost5 << &u32;
    actual = ost5.str();
    expected = "u64";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ch = false;
    Type *res = i32.meetWith(&flt, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost6;
    ost6 << res;
    actual = ost6.str();
    expected = "union";
    CPPUNIT_ASSERT_EQUAL(expected, actual);

    ch = false;
    res = i32.meetWith(&pt, ch, false);
    CPPUNIT_ASSERT(ch == true);
    std::ostringstream ost7;
    ost7 << res;
    actual = ost7.str();
    expected = "union";
    CPPUNIT_ASSERT_EQUAL(expected, actual);
}