OpenCV (c++): vscode hello-world

本文介绍了如何在VisualStudioCode(VSCode)中配置环境,实现OpenCV的基本操作,如读取图像并显示尺寸,以及如何加入自定义模块并使用其print函数。教程涵盖了tasks.json的修改和程序的编译与运行过程。
摘要由CSDN通过智能技术生成

目录

配置vscode

main.cpp

编译

运行

加入自己的模块

tasks.json修改

main.cpp


配置vscode

main.cpp
#include <iostream>
#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main(){
    cout <<"OpenCV"<<endl;
    Mat img = imread("/home/0001#_0.jpg");
    cout <<img.cols<<", "<<img.rows<<", "<<img.channels() << endl;
}
编译

运行

加入自己的模块

使用 手写print()函数里的printvi

tasks.json修改

main.cpp
#include <iostream>
#include <opencv2/opencv.hpp>
#include "diy_lib/pyfunc.h"
#include <vector>
using namespace cv;
using namespace std;

int main(){
    prints("OpenCV");

    Mat img = imread("/home/0001#_0.jpg");

    vector<int> shape = {img.cols,img.rows,img.channels()};
    printvi(shape);
}
OpenCV
[64, 128, 3]

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值