Python opencv 读取图片

网友投稿 620 2022-05-30

Python opencv 读取图片

环境信息

ModelArts

Notebook - pytorch1.4-cuda10.1-cudnn7-ubuntu18.04

JupyterLab - Notebook - Conda-python3

OpenCV 读取图片

import cv2 --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) in ----> 1 import cv2 ModuleNotFoundError: No module named 'cv2'

!pip install opencv-python Looking in indexes: http://repo.myhuaweicloud.com/repository/pypi/simple Collecting opencv-python Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/6b/73/a8921d221a673600dc744033786eeab56ed5116686a1b932b724a33003c6/opencv_python-4.5.3.56-cp37-cp37m-manylinux2014_x86_64.whl (49.9 MB) |████████████████████████████████| 49.9 MB 54.2 MB/s eta 0:00:01 | 7.1 MB 54.2 MB/s eta 0:00:01 | 9.7 MB 54.2 MB/s eta 0:00:01 | 11.8 MB 54.2 MB/s eta 0:00:01 | 15.5 MB 54.2 MB/s eta 0:00:014.2 MB/s eta 0:00:01 | 25.8 MB 54.2 MB/s eta 0:00:01 | 31.1 MB 54.2 MB/s eta 0:00:01��█████▏ | 37.6 MB 54.2 MB/s eta 0:00:01��███████████████████▎ | 44.2 MB 54.2 MB/s eta 0:00:01 Requirement already satisfied: numpy>=1.14.5 in /home/ma-user/modelarts-sdk (from opencv-python) (1.21.0) Installing collected packages: opencv-python Successfully installed opencv-python-4.5.3.56

import cv2 img = cv2.imread("1.png") img array([[[255, 255, 255], [255, 255, 255], [255, 255, 255], ..., [255, 255, 255], [255, 255, 255], [255, 255, 255]], [[255, 255, 255], [255, 255, 255], [255, 255, 255], ..., [255, 255, 255], [255, 255, 255], [255, 255, 255]], [[255, 255, 255], [255, 255, 255], [255, 255, 255], ..., [255, 255, 255], [255, 255, 255], [255, 255, 255]], ..., [[255, 255, 255], [255, 255, 255], [255, 255, 255], ..., [255, 255, 255], [255, 255, 255], [255, 255, 255]], [[255, 255, 255], [255, 255, 255], [255, 255, 255], ..., [255, 255, 255], [255, 255, 255], [255, 255, 255]], [[255, 255, 255], [255, 255, 255], [255, 255, 255], ..., [255, 255, 255], [255, 255, 255], [255, 255, 255]]], dtype=uint8)

help

help(cv2.imread) Help on built-in function imread: imread(...) imread(filename[, flags]) -> retval . @brief Loads an image from a file. . . @anchor imread . . The function imread loads an image from the specified file and returns it. If the image cannot be . read (because of missing file, improper permissions, unsupported or invalid format), the function . returns an empty matrix ( Mat::data==NULL ). . . Currently, the following file formats are supported: . . - Windows bitmaps - \*.bmp, \*.dib (always supported) . - JPEG files - \*.jpeg, \*.jpg, \*.jpe (see the *Note* section) . - JPEG 2000 files - \*.jp2 (see the *Note* section) . - Portable Network Graphics - \*.png (see the *Note* section) . - WebP - \*.webp (see the *Note* section) . - Portable image format - \*.pbm, \*.pgm, \*.ppm \*.pxm, \*.pnm (always supported) . - PFM files - \*.pfm (see the *Note* section) . - Sun rasters - \*.sr, \*.ras (always supported) . - TIFF files - \*.tiff, \*.tif (see the *Note* section) . - OpenEXR Image files - \*.exr (see the *Note* section) . - Radiance HDR - \*.hdr, \*.pic (always supported) . - Raster and Vector geospatial data supported by GDAL (see the *Note* section) ......

相关链接

Python入门篇

Python进阶篇

Python应用篇

帮助文档-AI开发平台ModelArts

【生长吧!Python】有奖征文火热进行中

备注

欢迎各位同学一起来交流学习心得^_^

在线课程、沙箱实验、认证、论坛和直播,其中包含了许多优质的内容,推荐了解与学习。

AI开发平台ModelArts OpenCV Python

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:手把手教Golang小白搭建小米SOAR开发环境
下一篇:apipost 使用脚本发送一个接口请求
相关文章