本文整理汇总了C++中cv::VideoCapture类的典型用法代码示例。如果您正苦于以下问题:C++ VideoCapture类的具体用法?C++ VideoCapture怎么用?C++ VideoCapture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VideoCapture类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: capture
VCrop::VCrop(cv::VideoCapture &capture, const float &x, const float &y, const float &size) : capture(&capture) {
if (!capture.isOpened()) {
std::string error_message = "Error when reading input stream";
LOG(ERROR) << error_message;
throw error_message;
}
int frame_width = capture.get(CV_CAP_PROP_FRAME_WIDTH);
int frame_height = capture.get(CV_CAP_PROP_FRAME_HEIGHT);
VLOG(2) << "Frame Width: " << frame_width;
VLOG(2) << "Frame Height: " << frame_height;
LOG_IF(FATAL, frame_width <= 0) << "Frame width is less than zero.";
LOG_IF(FATAL, frame_height <= 0) << "Frame height is less than zero.";
float diameter = sqrt(frame_width * frame_width + frame_height * frame_height);
cv::Point2i top_left(frame_width * x, frame_height * y);
cv::Size2i rect_size(diameter * size, diameter * size);
if (top_left.x + rect_size.width > frame_width || top_left.y + rect_size.height > frame_height) {
LOG(ERROR) << "Size(" << rect_size << ") to too large for given x(" << top_left.x << ") and y(" << top_left.y << ") coordinate.";
}
roi = new cv::Rect(top_left, rect_size);
VLOG(1) << "RoI: \t" << *roi;
frame_rate = capture.get(CV_CAP_PROP_FPS);
if (isnan(frame_rate) || frame_rate <= 0) {
LOG(WARNING) << "Failed to get frame rate, setting rate to 10fps.";
frame_rate = 10;
}
VLOG(1) << "Frame Rate: \t" << frame_rate;
}
开发者ID:Kazz47,项目名称:my_utils,代码行数:29,代码来源:vcrop.cpp
示例2: initVideoStream
void initVideoStream(cv::VideoCapture &cap)
{
if (cap.isOpened())
cap.release();
cap.open(0); // open the default camera
}
开发者ID:sokke90,项目名称:MAR-s1,代码行数:7,代码来源:main.cpp
示例3: readFrameIndex
cv::Mat readFrameIndex(cv::VideoCapture cap, int frameNum){
int idx = frameNum-1;
cv::Mat frame;
bool success;
cap.set ( CV_CAP_PROP_POS_FRAMES , idx );
success = cap.retrieve(frame);
return frame;
}
开发者ID:vadimgg,项目名称:Quadcopter495,代码行数:8,代码来源:main.cpp
示例4: openVideo
static int openVideo(cv::VideoCapture &capture, std::string filename){
std::cout << "abriendo video " << filename << std::endl;
capture.open(filename);
if (!capture.isOpened()) {
std::cout << "abriendo camara " << filename << std::endl;
int id_webcam = std::atoi(filename.c_str());
capture.open(id_webcam);
}
if (!capture.isOpened()) {
// std::cout << "no puedo abrir " << filename << std::endl;
return 0;
}
return 1;
}
开发者ID:fquintan,项目名称:DetectorComerciales,代码行数:14,代码来源:Utils.cpp
示例5: readParameters
bool readParameters(int argc, char** argv)
{
if (argc<4) {
usage();
return false;
}
TheInputVideo=argv[1];
/* // read input video
if (TheInputVideo=="live") TheVideoCapturer.open(0);
else TheVideoCapturer.open(argv[1]);
if (!TheVideoCapturer.isOpened())
{
cerr<<"Could not open video"<<endl;
return false;
}*/
//read from camera
if (TheInputVideo=="live") TheVideoCapturer.open(0);
else TheVideoCapturer.open(TheInputVideo);
if (!TheVideoCapturer.isOpened())
{
cerr<<"Could not open video"<<endl;
return -1;
}
// read intrinsic file
try {
CameraParams.readFromXMLFile(argv[2]);
} catch (std::exception &ex) {
cout<<ex.what()<<endl;
return false;
}
// read board file
try {
TheBoardConfig.readFromFile(argv[3]);
} catch (std::exception &ex) {
cout<<ex.what()<<endl;
return false;
}
if(argc>4) TheMarkerSize=atof(argv[4]);
else TheMarkerSize=1.;
return true;
}
开发者ID:maurosc3ner,项目名称:augmentedLimbs,代码行数:48,代码来源:aruco_test_board_ogre.cpp
示例6: VideoCaptureManager
VideoCaptureManager()
: cap_(0)
{
if(!cap_.isOpened()){
std::cerr << "failed to open" << std::endl;
}
}
开发者ID:michiroooo,项目名称:cppcv,代码行数:7,代码来源:main.cpp
示例7: fx
void fx(ForParameter for_param, cv::VideoCapture & capture_dx){
UMat *frame_dx = new UMat[farm_size];
UMat image_dx;
Mat *canvas_dx = new Mat[farm_size];
double scale_dx = 1;
CascadeClassifier *cascade_dx = new CascadeClassifier[farm_size];
for(int i = 0; i < farm_size; i ++)
cascade_dx[i].load(cascadeName);
cout << "Video dx capturing has been started ..." << endl;
bool frame_success;
int count = 0;
while(count < 220) {
for(int j = 0; j < farm_size; j ++)
frame_success = capture_dx.read(frame_dx[j]);
if (!frame_success) break;
dx(frame_dx, canvas_dx, cascade_dx, scale_dx, count);
count ++;
}
launch_todo_job();
}
开发者ID:filippobrizzi,项目名称:soma,代码行数:26,代码来源:ufacedetect_transformed.cpp
示例8: openCamera
void openCamera(cv::VideoCapture& cap, int argc, const char** argv) {
cv::CommandLineParser parser(argc, argv, keys);
int camNum = parser.get<int>("1");
cap.open(camNum);
if (!cap.isOpened()) {
//help();
std::cout << "***Could not initialize capturing...***\n";
std::cout << "Current parameter's value: \n";
exit (-1);
}
cap.set(CV_CAP_PROP_FRAME_WIDTH, 160);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 120);
}
开发者ID:peterborkuti,项目名称:opencv,代码行数:16,代码来源:main.cpp
示例9: skipNFrames
/*
* Skip n frames returning the n+1 frame. Returns NULL if no frames are
* available.
*/
bool skipNFrames(cv::VideoCapture capture, int n, cv::Mat *image) {
for(int i = 0; i < n + 1; i++) {
if(!capture.read(*image)) {
return false;
}
}
return true;
}
开发者ID:RemchoResearchGroup,项目名称:OccuChrome-GitHub,代码行数:13,代码来源:imgtest.cpp
示例10: GetFrames
std::vector<Mat> GetFrames(cv::VideoCapture &cap)
{
std::vector<Mat> ansvect;
for(int i=0;;i++)
{
//std::cout << i <<"\n";
cv::Mat frame;
if (int(cap.get(CV_CAP_PROP_POS_FRAMES)) == int(cap.get(CV_CAP_PROP_FRAME_COUNT)))
break;
//std::cout << cap.get(CV_CAP_PROP_POS_FRAMES) <<"\t"<<cap.get(CV_CAP_PROP_FRAME_COUNT) <<"\n";
if (!cap.read(frame))
break;
ansvect.push_back(frame);
//cv::imshow("window", frame);
//char key = cvWaitKey(0);
}
return ansvect;
}
开发者ID:kartikeyagup,项目名称:SURA-Work,代码行数:18,代码来源:VideoTracking.cpp
示例11: Init
void Init(cv::VideoCapture& capture)
{
if(!capture.isOpened()){
std::cout << "error starting video capture" << std::endl;
exit(0);
}
//propose a resolution
capture.set(CV_CAP_PROP_FRAME_WIDTH, RESOLUTION_X);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, RESOLUTION_Y);
//get the actual (supported) resolution
ivWidth = capture.get(CV_CAP_PROP_FRAME_WIDTH);
ivHeight = capture.get(CV_CAP_PROP_FRAME_HEIGHT);
std::cout << "camera/video resolution: " << ivWidth << "x" << ivHeight << std::endl;
cv::namedWindow("MOCTLD", 0); //CV_WINDOW_AUTOSIZE );
// cv::resizeWindow("MOCTLD", ivWidth, ivHeight);
cv::setMouseCallback("MOCTLD", MouseHandler);
}
开发者ID:Overdr0ne,项目名称:motld,代码行数:18,代码来源:camExample.cpp
示例12: showVideoInfo
void VirtualKinect::showVideoInfo(cv::VideoCapture& video)
{
#if (defined WIN32 || defined _WIN32 || defined WINCE) // for Windows
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_GREEN);
#endif
std::cout << cv::format("frame count:%.0f, size (%.0f,%.0f), fps:%.2f, fourcc:",
video.get(CV_CAP_PROP_FRAME_COUNT),
video.get(CV_CAP_PROP_FRAME_WIDTH),
video.get(CV_CAP_PROP_FRAME_HEIGHT),
video.get(CV_CAP_PROP_FPS));
int ex = static_cast<int>(video.get(CV_CAP_PROP_FOURCC)); // Get Codec Type- Int form
char EXT[] = {(char)(ex & 0XFF) , (char)((ex & 0XFF00) >> 8),(char)((ex & 0XFF0000) >> 16),(char)((ex & 0XFF000000) >> 24), 0};
std::cout << EXT << std::endl << std::endl;
#if (defined WIN32 || defined _WIN32 || defined WINCE) // for Windows
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
#endif
}
开发者ID:amazon-picking-challenge,项目名称:team_nanyang,代码行数:20,代码来源:VirtualKinect.cpp
示例13: readAndSet
void initParams::readAndSet(cv::VideoCapture& cap, char* input){
cv::FileStorage fs(input, cv::FileStorage::READ);
if(fs.isOpened()){
fs.open(input, cv::FileStorage::READ);
fs["frameWidth"] >> frameWidth;
fs["frameHeight"] >> frameHeight;
fs["fps"] >> fps;
fs["camId"] >> camId;
fs["generateData"] >> genData;
fs["visualizeData"] >> visualize;
fs["writeVideo"] >> writeVideo;
fs["generatePerfData"] >> genPerfData;
fs["videoFile"] >> videoFile;
fs.release();
cap.open(videoFile);
if(!cap.isOpened()){
std::cerr << "Could not access video file: " << videoFile << std::endl;
exit(EXIT_FAILURE);
}
}
开发者ID:Ragesam,项目名称:Thesis,代码行数:21,代码来源:initParams.cpp
示例14: mono_handler
void mono_handler(const lcm_recv_buf_t *rbuf, const char* channel, const lcmt_stereo *msg, void *user) {
// open the frame of the video specified by the message
// check to see if the current video is the correct video file
if (current_video_number != msg->video_number) {
video_capture.release();
std::string newfile = GetMonoFilename(msg->timestamp, msg->video_number);
if (newfile.empty()) {
return;
}
std::cout << "Opening file: " << newfile << std::endl;
if (!video_capture.open(newfile)) {
std::cerr << "Failed to open file: " << newfile << std::endl;
return;
}
current_video_number = msg->video_number;
}
video_capture.set(CV_CAP_PROP_POS_FRAMES, msg->frame_number + frame_offset);
cv::Mat frame;
video_capture >> frame;
SendImageOverLcm(lcm_, image_channel, frame);
}
开发者ID:fengmushu,项目名称:flight,代码行数:33,代码来源:mono-playback.cpp
示例15: InitOpenCVModules
void InitOpenCVModules() //OPENCV 데이터들의 초기화
{
/*----------------------*/
//
//
//
//
/*-----------------------*/
if (Webcam_mode)
{
camera.open(Webcam_number);
if (!camera.isOpened()) //소스 영상 에러체크
{
//error in opening the video input
cerr << "Unable to open Camera Stream" << endl;
exit(EXIT_FAILURE);
}
camera >> Current_Frame; //카메라 소스에서 Current Frame으로 데이터를 넣어준다.
}
else
{
开发者ID:jhseong7,项目名称:Gait-Recognition-MoG-Fast,代码行数:27,代码来源:Main.cpp
示例16: open
bool SubsExtractor::open(string file)
{
videofile = file;
bool o = cap->open(videofile);
StartFrame = 0;
EndFrame = cap->get(CV_CAP_PROP_FRAME_COUNT);
return o;
}
开发者ID:egrosclaude,项目名称:subs,代码行数:8,代码来源:subsextractor.cpp
示例17: shutterCB
void shutterCB(int pos, void* param){
struct timeval t;
cap.set(CV_CAP_PROP_EXPOSURE,pos);
//fcount=0; // Reset frame counter, so we dont have do wait for the avg to "catch" up
std::cout << "CALLBACK !!!: pos: " << pos << "Shutter read: " << cap.get(CV_CAP_PROP_EXPOSURE) << std::endl;
}
开发者ID:swiatecki,项目名称:ProjectMoose,代码行数:11,代码来源:bwcontroller.cpp
示例18: init_opencv
bool init_opencv()
{
if (!capture.open(0)) {
std::cerr << "error: capture.open() failed..." << std::endl;
exit(-1);
}
capture.set(CV_CAP_PROP_FRAME_WIDTH, 640);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, 480);
result_img.create(cv::Size(640, 480), CV_8UC3);
return true;
}
开发者ID:yoggy,项目名称:pi_sdl_test,代码行数:13,代码来源:main_pi_sdl_test.cpp
示例19: grabFunc
void* grabFunc(void* in_data)
{
while(running)
{
pthread_mutex_lock(&mutexLock);
if(camera.isOpened())
{
camera.grab();
}
pthread_mutex_unlock(&mutexLock);
}
std::cout << "Grab thread exit." << std::endl;
}
开发者ID:MakerCollider,项目名称:Xpider_Mark2,代码行数:14,代码来源:xpider_facetrack.cpp
示例20: cameraInit
void cameraInit(){
/*
cv::Mat frame;
cap >> frame; // get a new frame from camera
//cvtColor(frame, edges, CV_BGR2GRAY);
//GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
//Canny(edges, edges, 0, 30, 3);
imshow("edges", frame);
cv::waitKey(30);
}
*/
cap.set(CV_CAP_PROP_FRAME_WIDTH,1280);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,720);
cap.set(CV_CAP_PROP_FPS, 30);
}
开发者ID:jamesmorrisstudios,项目名称:Senior_Design_PC,代码行数:15,代码来源:Triangulation.cpp
注:本文中的cv::VideoCapture类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论