当前位置: 首页>>代码示例>>C++>>正文


C++ DCBuffer::unpack方法代码示例

本文整理汇总了C++中DCBuffer::unpack方法的典型用法代码示例。如果您正苦于以下问题:C++ DCBuffer::unpack方法的具体用法?C++ DCBuffer::unpack怎么用?C++ DCBuffer::unpack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DCBuffer的用法示例。


在下文中一共展示了DCBuffer::unpack方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........

    std::string dim_timestamp = get_dim_output_timestamp();
    layout.set_param_all("dim_timestamp", dim_timestamp);

    DCFilter * console_filter = layout.execute_start();
    DCBuffer * imgstr = new DCBuffer(image_descriptor_string.size()+1);
    imgstr->pack("s", image_descriptor_string.c_str());
    console_filter->write_broadcast(imgstr, "to_warper");
    delete imgstr;
    for (u = 0; u < jxd->num_control_points; u++) {
        DCBuffer * out = new DCBuffer(4 * sizeof(float) + sizeof(uint));
/*
        cout << jxd->correspondences[u]->origin_x <<  " " << 
                           jxd->correspondences[u]->origin_y <<  " " <<
                           jxd->correspondences[u]->endpoint_x <<  " " <<
                           jxd->correspondences[u]->endpoint_y <<  " " <<
                           jxd->correspondences[u]->weight << endl;
*/

        out->pack("ffffi", jxd->correspondences[u]->origin_x, 
                           jxd->correspondences[u]->origin_y, 
                           jxd->correspondences[u]->endpoint_x, 
                           jxd->correspondences[u]->endpoint_y, 
                           jxd->correspondences[u]->weight);
        console_filter->write_broadcast(out, "to_warper");
    }

    std::map<ImageCoordinate, std::pair<std::string, int8> > newfiles;
    for (u = 0; u < descriptor.parts.size(); u++) {
        DCBuffer * in = console_filter->read("from_warpwriter");
        ImageCoordinate ic;
        std::string output_filename;
        int8 output_offset;
        in->unpack("iiisl", &ic.x, &ic.y, &ic.z,
                   &output_filename, &output_offset);
        newfiles[ic] = make_pair(output_filename, output_offset);
        delete in;
    }

    rc = layout.execute_finish();
    if (rc) {
        std::cerr << "ERROR: layout.execute() returned " << rc
                  << " at " << __FILE__ << ":" << __LINE__
                  << std::endl << std::flush;
        exit(1);
    }
    else {
        std::string message = "type BGRplanar\n";
        message += "pixels_x " + tostr(descriptor.pixels_x) + "\n";
        message += "pixels_y " + tostr(descriptor.pixels_y) + "\n";
        message += "pixels_z " + tostr(descriptor.pixels_z) + "\n";
        message += "chunks_x " + tostr(descriptor.chunks_x) + "\n";
        message += "chunks_y " + tostr(descriptor.chunks_y) + "\n";
        message += "chunks_z " + tostr(descriptor.chunks_z) + "\n";
        message += "chunk_dimensions_x";
        for (u = 0; u < descriptor.chunks_x; u++) {
            message += " ";
            message += tostr(descriptor.chunk_dimensions_x[u]);
        }
        message += "\n";
        message += "chunk_dimensions_y";
        for (u = 0; u < descriptor.chunks_y; u++) {
            message += " ";
            message += tostr(descriptor.chunk_dimensions_y[u]);
        }
        message += "\n";
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:67,代码来源:ocvmwarp.cpp

示例2: answer_ps_queries


//.........这里部分代码省略.........


        while (1) {
            if (prefix_sum_descriptor.bottommost_pixel_next_chunk_up(
                    psx, psy, new_x, new_y) == false) {
                break;
            }
            INSERT(new_x, new_y);
            psx = new_x;
            psy = new_y;
        }

        psx = it->x / tess_x;
        psy = it->y / tess_y;
        while (1) {
            if (prefix_sum_descriptor.rightmost_pixel_next_chunk_to_the_left(
                    psx, psy, new_x, new_y) == false) {
                break;
            }
            INSERT(new_x, new_y);
            psx = new_x;
            psy = new_y;
        }
        psx = it->x / tess_x;
        psy = it->y / tess_y;
        INSERT(psx, psy);
    }
    std::cout << "request_set: ";
    std::copy(request_set.begin(), request_set.end(), ostream_iterator<PixelReq>(cout, " ")); cout << endl;


    DCBuffer pointsbuf;
    request_set.serialize(&pointsbuf);
    console_filter->write_broadcast(&pointsbuf, "0");
    int4 scalar;
    int color = 0;
    int i;
    std::map<PixelReq, std::vector<int4> > fetch_results;
    for (i = 0; i < hosts.size(); i++) {
        DCBuffer * reply = console_filter->read("fromreader");
        std::string from_host;
        reply->unpack("s", &from_host);
        while (reply->getExtractAvailSize()) {
            PixelReq req;
            req.deSerialize(reply);
            std::vector<int4> tuple3;
            for (color = 0; color < 3; color++) {
                std::cout << "reply from host " << from_host
                          << ", pixelreq " << req
                          << ", color " << color << ": ";
                reply->unpack("i", &scalar);
                tuple3.push_back(scalar);
                std::cout << scalar << "\n";
            }
            fetch_results[req] = tuple3;
        }
        delete reply;
    }

    std::map<PixelReq, std::vector<int8> > sum_results;
    for (it = query_points.begin();
         it != query_points.end();
         it++) {
        const PixelReq & querypoint = *it;
        const std::vector<PixelReq> & needed_points =
            querypoint_pspoints[querypoint];
        std::vector<int8> single_sum_results;
        single_sum_results.push_back(0);
        single_sum_results.push_back(0);
        single_sum_results.push_back(0);
        uint np;
        for (np = 0; np < needed_points.size(); np++) {
            const PixelReq & needed_point = needed_points[np];
            std::vector<int> & lookup = fetch_results[needed_point];
            for (color = 0; color < 3; color++) {
                single_sum_results[color] += lookup[color];
            }
        }
        sum_results[querypoint] = single_sum_results;
        if (cached_contributions.count(querypoint) > 0) {
            std::cout << "cache hit for querypoint "
                      << querypoint << endl;
            std::vector<int> & cache = cached_contributions[querypoint];
            for (color = 0; color < 3; color++) {
                sum_results[querypoint][color] += cache[color];
                std::cout << "hit for color " << color
                          << ": " << cache[color] << endl;
            }
        }
        else {
            std::cout << "cache miss for querypoint "
                      << querypoint << endl;
        }
    }

    for (i = 0; i < query_points.size(); i++) {
        results.push_back(sum_results[query_points[i]]);
    }
    return 0;
}
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:101,代码来源:ocvmquerylib.cpp

示例3: process

int ocvm_dim_writer::process()
{
    std::string output_directory;
    int x1, y1, x2, y2, z;
    int i, j;
    DCBuffer * in;
    const char * mode;
    //while (1) {
        //in = read_until_upstream_exit("0");
        in = read("0");
        //if (!in) {
        //    break;
        //}
        in->unpack("siiiii", 
                   &output_directory, &x1, &y1,
                   &x2, &y2, &z);
        in->consume();
//         cout << "dimwriter on " << dcmpi_get_hostname()
//              << ": writing to "
//              << output_filename << endl;
        std::string containing_dir = dcmpi_file_dirname(output_directory);
        if (!dcmpi_file_exists(containing_dir)) {
            if (dcmpi_mkdir_recursive(containing_dir)) {
                std::cerr << "ERROR: making directories on "
                          << dcmpi_get_hostname()
                          << " at " << __FILE__ << ":" << __LINE__
                          << std::endl << std::flush;
            }
        }
        assert(dcmpi_file_exists(containing_dir));

        FILE * f;
        mode = "w";

        for (i = y1; i <= y2; i++) {
            for (j = x1; j <= x2; j++) {
                std::string output_filename = output_directory + tostr(j) + "_" + tostr(i) + "_0";
                if ((f = fopen(output_filename.c_str(), mode)) == NULL) {
                    std::cerr << "ERROR: opening " << output_filename
                              << " for mode " << mode
                              << " on host " << dcmpi_get_hostname()
                              << " at " << __FILE__ << ":" << __LINE__
                              << std::endl << std::flush;
                    exit(1);
                }

                in = read("0");
                if (compress) {
                    in->decompress();
                }

                if (fwrite(in->getPtr(), in->getUsedSize(), 1, f) < 1) {
                    std::cerr << "ERROR: calling fwrite()"
                              << " at " << __FILE__ << ":" << __LINE__
                              << std::endl << std::flush;
                    exit(1);
                }

                in->consume();
                
                if (fclose(f) != 0) {
                    std::cerr << "ERROR: calling fclose()"
                              << " at " << __FILE__ << ":" << __LINE__
                              << std::endl << std::flush;
                    exit(1);
                }
            }
        }

    //}
    return 0;
}
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:72,代码来源:f-dimwriter.cpp

示例4: while

int ocvm_dim_writer2::process()
{
    std::cout << "dim writer on "
              << get_bind_host()
              << " launching\n" << flush;

    DCBuffer * in;
    std::string output_filename;
    std::string mode;
    std::vector<std::string> dirs_made;
    std::vector<std::string> dirs_rename_to;
    while (1) {
        in = read_until_upstream_exit("0");
        if (!in) {
           break;
        }
        in->unpack("ss", &output_filename, &mode);
        std::string d = dcmpi_file_dirname(output_filename);
        std::string tstamp = dcmpi_file_basename(d);
        std::string scratch_dir = dcmpi_file_dirname(d);
        std::string temporary_dir = scratch_dir + "/.tmp." + tstamp;
        std::string new_filename =
            temporary_dir + "/" + dcmpi_file_basename(output_filename);
        
        if (!dcmpi_file_exists(temporary_dir)) {
            if (dcmpi_mkdir_recursive(temporary_dir)) {
                if (errno != EEXIST) {
                    std::cerr << "ERROR: making directory " << temporary_dir
                              << " on " << dcmpi_get_hostname()
                              << " at " << __FILE__ << ":" << __LINE__
                              << std::endl << std::flush;
                    exit(1);
                }
            }
            else {                
                dirs_made.push_back(temporary_dir);
                dirs_rename_to.push_back(scratch_dir + "/" + tstamp);
            }
        }
        assert(dcmpi_file_exists(temporary_dir));

        FILE * f;
        if ((f = fopen(new_filename.c_str(), mode.c_str())) == NULL) {
            std::cerr << "ERROR: opening " << new_filename
                      << " for mode " << mode
                      << " on host " << dcmpi_get_hostname()
                      << " at " << __FILE__ << ":" << __LINE__
                      << std::endl << std::flush;
            exit(1);
        }
        if (fwrite(in->getPtrExtract(), in->getExtractAvailSize(), 1, f) < 1) {
            std::cerr << "ERROR: calling fwrite()"
                      << " at " << __FILE__ << ":" << __LINE__
                      << std::endl << std::flush;
            exit(1);
        }
        if (fclose(f) != 0) {
            std::cerr << "ERROR: calling fclose()"
                      << " at " << __FILE__ << ":" << __LINE__
                      << std::endl << std::flush;
            exit(1);
        }
        delete in;
    }

    // barrier
    int nwriters = get_param_as_int("nwriters");
    if (nwriters > 1) {
        DCBuffer broadcast;
        write_broadcast(&broadcast, "barrier");
        for (int i = 0; i < nwriters-1; i++) {
            DCBuffer* input = read ("barrier");
            delete input;
        }
    }
    
    for (unsigned int u = 0; u < dirs_made.size(); u++) {
        rename(dirs_made[u].c_str(), dirs_rename_to[u].c_str());
    }

    std::cout << "dim writer on "
              << get_bind_host()
              << " exiting\n";
    
    return 0;
}
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:86,代码来源:f-dimwriter.cpp

示例5: main


//.........这里部分代码省略.........
        layout.add_port(scaler, "to_console", &console, "from_scaler");
    }
    std::vector< std::string> dest_hosts;
    std::vector< std::string> client_hosts;
    if (non_local_destination) {
        dest_hosts = dest_host_scratch->get_hosts();
    }
    if (non_local_clients) {
        client_hosts = client_host_scratch->get_hosts();
    }
    MediatorInfo info = mediator_setup(layout, 1, 1, input_hosts, client_hosts, dest_hosts);
    mediator_add_client(layout, info, scalers);
    mediator_add_client(layout, info, rangefetchers);
    double before = dcmpi_doubletime();
    std::string dim_timestamp = get_dim_output_timestamp();
    layout.set_param_all("dim_timestamp", dim_timestamp);
    layout.set_param_all("xs", tostr(xs));
    layout.set_param_all("ys", tostr(ys));
    layout.set_param_all("zs", tostr(zs));

    DCFilter * console_filter = layout.execute_start();
    std::map<ImageCoordinate, std::vector<std::string> > newfiles;
    int newparts = xs*ys*zs*
        original_image_descriptor.chunks_x*
        original_image_descriptor.chunks_y*
        original_image_descriptor.chunks_z;
    std::cout << "newparts " << newparts << endl;
    for (u = 0; u < newparts; u++) {
        DCBuffer * in = console_filter->read("from_scaler");
        ImageCoordinate ic;
        std::string hn;
        std::string output_filename;
        int8 output_offset;
        in->unpack("siiisl", &hn, &ic.x, &ic.y, &ic.z,
                   &output_filename, &output_offset);
        std::vector<std::string> v;
        v.push_back(hn);
        v.push_back(output_filename);
        v.push_back(tostr(output_offset));
        newfiles[ic] = v;
        delete in;
    }

    rc = layout.execute_finish();
    if (rc) {
        std::cerr << "ERROR: layout.execute() returned " << rc
                  << " at " << __FILE__ << ":" << __LINE__
                  << std::endl << std::flush;
        exit(1);
    }
    else {
        int i;
        std::string message = "type BGRplanar\n";
        message += "pixels_x " + tostr(original_image_descriptor.pixels_x*xs)+"\n";
        message += "pixels_y " + tostr(original_image_descriptor.pixels_y*ys)+"\n";
        message += "pixels_z " + tostr(original_image_descriptor.pixels_z*zs)+"\n";
        message += "chunks_x " + tostr(original_image_descriptor.chunks_x*xs)+"\n";
        message += "chunks_y " + tostr(original_image_descriptor.chunks_y*ys)+"\n";
        message += "chunks_z " + tostr(original_image_descriptor.chunks_z*zs)+"\n";

        message += "chunk_dimensions_x";
        for (i = 0; i < xs; i++) {
            for (u = 0; u < original_image_descriptor.chunks_x; u++) {
                message += " ";
                message += tostr(original_image_descriptor.chunk_dimensions_x[u]);
            }
开发者ID:vijayskumar,项目名称:bigdata-virtual-microscope,代码行数:67,代码来源:ocvmdimscaler.cpp


注:本文中的DCBuffer::unpack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。