当前位置:网站首页>gocv图片裁剪并展示
gocv图片裁剪并展示
2022-07-02 06:30:00 【图图是只猫】
gocv实现图片裁剪
新建窗口
window := gocv.NewWindow("Hello")
读取图片
read := gocv.IMRead("image/front.jpg", gocv.IMReadColor)
类型转换
frontImg, _ := read.ToImage()
颜色类型
rgbImg := frontImg.(*image.RGBA)
图片切割 :Rect函数中 (950,100)左上角坐标,左下角坐标(1300,700)即可切割为矩形
subImg := rgbImg.SubImage(image.Rect(950, 100, 1300, 700)).(*image.RGBA)
存储图片
out, _ := os.Create("image/front_face.jpg")
png.Encode(out, subImg)
读取图片
result := gocv.IMRead("image/front_face.jpg",gocv.IMReadColor)
根据上述图片大小设置窗口大小
window.ResizeWindow(1300-950,700-100)
图片展示到窗口
window.IMShow(result)
window.WaitKey(0)
边栏推荐
猜你喜欢

web安全--逻辑越权

Qunhui NAS configuring iSCSI storage

Data asset management function

TCP/IP—传输层

Hcia - Application Layer

sqli-labs第12关

OpenShift构建镜像

2022 Heilongjiang's latest eight member (Safety Officer) simulated test question bank and answers

Kubesphere virtualization KSV installation experience

Realization of basic function of sequence table
随机推荐
KubeSphere 虚拟化 KSV 安装体验
Luogu greedy part of the backpack line segment covers the queue to receive water
路由基础—动态路由
Data asset management function
Hcia - Application Layer
Makefile基本原理
Tcp/ip - transport layer
OpenFeign 简单使用
ARP and ARP Spoofing
Development of digital collection trading website development of metauniverse digital collection
实现双向链表(带傀儡节点)
Installation and use of simple packaging tools
Kubedm deploys kubernetes v1.23.5 cluster
Driving test Baodian and its spokesperson Huang Bo appeared together to call for safe and civilized travel
ARP及ARP欺骗
Dip1000 implicitly tagged with fields
Sqli labs level 1
STM32-新建工程(参考正点原子)
HCIA—應用層
顺序表基本功能函数的实现