OpenCV中文网站

 找回密码
 立即注册
搜索
热搜: 安装 配置
查看: 3568|回复: 2

摄像头调用出错,请教

[复制链接]
发表于 2018-10-19 20:45:49 | 显示全部楼层 |阅读模式
报错内容如下:
chris@chris-TM1701:~/opencv/VideoCapture/build$ make
Scanning dependencies of target Videocapture
[ 50%] Building CXX object CMakeFiles/Videocapture.dir/Videocapture.cpp.o
[100%] Linking CXX executable Videocapture
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:在函数‘_start’中:
(.text+0x20):对‘main’未定义的引用
collect2: error: ld returned 1 exit status
CMakeFiles/Videocapture.dir/build.make:135: recipe for target 'Videocapture' failed
make[2]: *** [Videocapture] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/Videocapture.dir/all' failed
make[1]: *** [CMakeFiles/Videocapture.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2


萌新求解,,

代码
#include<iostream>
#include<opencv2/opencv.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int mian()
{
    VideoCapture capture(0);
    while(true)
    {
        Mat frame;
        capture>>frame;
        imshow("Video",frame);
        waitKey(30);
    }
    return 0;
}



CMakeLists.txt 文件
cmake_minimum_required( VERSION 2.8 )
project( Videocapture )
#set( CMAKE_CXX_FLAGS "-std=c++11" )
find_package( OpenCV 3 REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( Videocapture Videocapture.cpp)
target_link_libraries( Videocapture ${OpenCV_LIBS})



回复

使用道具 举报

发表于 2018-10-26 16:27:56 | 显示全部楼层
VideoCapture capture(0);
这个改成
VideoCapture capture(-1);

VideoCapture capture(1);
试试..

或者看看这个demo,看看别人是怎么调用的
http://www.opencv.org.cn/opencvd ... #cascade-classifier

回复 支持 反对

使用道具 举报

发表于 2018-11-2 13:46:37 | 显示全部楼层
int mian()
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|OpenCV中文网站

GMT+8, 2024-4-24 16:44 , Processed in 0.011465 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表