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


C++ cv::waitKey方法代码示例

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


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

示例1: display

int display(Mat im, CMT & cmt)
{
    //Visualize the output
    //It is ok to draw on im itself, as CMT only uses the grayscale image
    for(size_t i = 0; i < cmt.points_active.size(); i++)
    {
        circle(im, cmt.points_active[i], 2, Scalar(0, 255, 0));
    }

    Scalar color;
    if (cmt.confidence < 0.3) {
      color = Scalar(0, 0, 255);
    } else if (cmt.confidence < 0.4) {
      color = Scalar(0, 255, 255);
    } else {
      color = Scalar(255, 0, 0);
    }
    Point2f vertices[4];
    cmt.bb_rot.points(vertices);
    for (int i = 0; i < 4; i++)
    {
        line(im, vertices[i], vertices[(i+1)%4], color);
    }

    imshow(WIN_NAME, im);

    return waitKey(5);
}
开发者ID:mvines,项目名称:CppMT,代码行数:28,代码来源:main.cpp

示例2: display

int display(Mat im, CMT & cmt)
{
    //Visualize the output
    //It is ok to draw on im itself, as CMT only uses the grayscale image
    for(size_t i = 0; i < cmt.points_active.size(); i++)
    {
        circle(im, cmt.points_active[i], 2, Scalar(255,0,0));
    }

    Point2f vertices[4];
    cmt.bb_rot.points(vertices);
    for (int i = 0; i < 4; i++)
    {
        line(im, vertices[i], vertices[(i+1)%4], Scalar(255,0,0));
    }

    imshow(WIN_NAME, im);

    return waitKey(CV_UPDATE_TIME);
}
开发者ID:andrewramsay,项目名称:cmt-uvc-realsense,代码行数:20,代码来源:main.cpp

示例3: main


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

        if (skip_frames > 0)
        {
          cap.set(CV_CAP_PROP_POS_FRAMES, skip_frames);
        }

        if (skip_msecs > 0)
        {
          cap.set(CV_CAP_PROP_POS_MSEC, skip_msecs);

          // Now which frame are we on?
          skip_frames = (int) cap.get(CV_CAP_PROP_POS_FRAMES);
        }

        show_preview = false;
    }

    //If it doesn't work, stop
    if(!cap.isOpened())
    {
        cerr << "Unable to open video capture." << endl;
        return -1;
    }

    //Show preview until key is pressed
    while (show_preview)
    {
        Mat preview;
        cap >> preview;

        screenLog(preview, "Press a key to start selecting an object.");
        imshow(WIN_NAME, preview);

        char k = waitKey(10);
        if (k != -1) {
            show_preview = false;
        }
    }

    //Get initial image
    Mat im0;
    cap >> im0;

    //If no bounding was specified, get it from user
    if (!bbox_flag)
    {
        rect = getRect(im0, WIN_NAME);
    }

    FILE_LOG(logINFO) << "Using " << rect.x << "," << rect.y << "," << rect.width << "," << rect.height
        << " as initial bounding box.";

    //Convert im0 to grayscale
    Mat im0_gray;
    if (im0.channels() > 1) {
        cvtColor(im0, im0_gray, CV_BGR2GRAY);
    } else {
        im0_gray = im0;
    }

    //Initialize CMT
    cmt.initialize(im0_gray, rect);

    int frame = skip_frames;

    //Open output file.
开发者ID:tesYolan,项目名称:CppMT,代码行数:67,代码来源:main.cpp

示例4: main


//.........这里部分代码省略.........
    {
        cout << static_cast<int>(id) << " ";
    }
    cout << endl;

    for (const auto &id : ids)
    {
        vector<uint8_t> raw;
        PacketType type;

        cout << "examining " << static_cast<int>(id) << endl;

        for (const auto &pkt : pkts)
        {
            if (pkt.getID() == id)
            {
                size_t new_length = pkt.getOffset() +
                    static_cast<size_t>(pkt.getLength());

                type = pkt.getType();

                if (new_length > raw.size())
                {
                    raw.resize(new_length, 0);
                }

                for (size_t k = 0; k < pkt.getLength(); k++)
                {
                    raw[pkt.getOffset() + k] = pkt.getData()[k];
                }
            }
        }

        cout << "type: " << type << endl;

        cout << hex;
        for (size_t j = 0; j < 512; j++)
        {
            if (j > 0 && (j % 32) == 0)
            {
                cout << endl;
            }
            cout << (static_cast<unsigned int>(raw[j]) & 0xFF) << " ";
        }
        cout << endl;

        Mat img{Size(160, 120), CV_8UC3, raw.data()};
        Mat dst;

        //cvtColor(img, dst, CV_YUV2GRAY_UYVY);
        //cvtColor(img, dst, CV_YUV2GRAY_YUY2);
        //cvtColor(img, dst, CV_YUV2BGR_UYVY);
        //cvtColor(img, dst, CV_YUV2BGRA_UYVY);
        //cvtColor(img, dst, CV_YUV2BGR_YUY2);
        //cvtColor(img, dst, CV_YUV2BGR_YVYU);
        //cvtColor(img, dst, CV_YUV2BGRA_YUY2);
        //cvtColor(img, dst, CV_YUV2BGRA_YVYU);
        //cvtColor(img, dst, CV_YUV2GRAY_NV12);
        //cvtColor(img, dst, CV_YUV2BGR_NV12);
        cvtColor(img, dst, CV_YCrCb2BGR);

        imshow("Police Video", dst);
        waitKey(0);

        ofstream out_jpeg{"out.jpg", ofstream::binary};
        for (size_t j = 0; j < raw.size(); j++)
        {
            if (raw[j] == 0xFF && raw[j + 1] == 0xD8)
            {
                cout << "hit the start" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                j++;
            }
            else if (raw[j] == 0xFF && raw[j + 1] == 0xDB)
            {
                cout << "hit the start 2" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                j++;
            }
            else if (raw[j] == 0xFF && raw[j + 1] == 0xC0)
            {
                cout << "hit the start 3" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                j++;
            }
            else if (raw[j] == 0xFF && raw[j + 1] == 0xD9)
            {
                cout << "hit the end" << endl;
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 2);
                return 0;
            }
            else
            {
                out_jpeg.write(reinterpret_cast<char *>(raw.data() + j), 1);
            }
        }
    }

    return 0;
}
开发者ID:alexjlaberge,项目名称:473BodyCam,代码行数:101,代码来源:examine.cpp


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