Ferramentas do usuário

Ferramentas do site


opencv

Diferenças

Aqui você vê as diferenças entre duas revisões dessa página.

Link para esta página de comparações

Ambos lados da revisão anteriorRevisão anterior
Próxima revisão
Revisão anterior
opencv [2023/07/08 00:40] – [Pré-Requisitos] jdosopencv [2023/07/08 01:22] (atual) – [imread()] jdos
Linha 17: Linha 17:
 import sys import sys
  
 +#chama a funcao cv::imread e cria e armazena um objeto cv:Mat
 img = cv.imread(cv.samples.findFile("starry_night.jpg")) img = cv.imread(cv.samples.findFile("starry_night.jpg"))
 +
 +#verifica se a imagem foi carregada corretamente
 if img is None: if img is None:
    sys.exit("Could not read the image.")    sys.exit("Could not read the image.")
 +  
 +#cria uma janela para mostrar a imagem - arg1 = nome da janela, arg2 = obj cv:Mat
 cv.imshow("Display window", img) cv.imshow("Display window", img)
 +
 +#funcao cv:waitkey tempo de espera, entrada em milisegundos, '0' significa para sempre
 k = cv.waitKey(0) k = cv.waitKey(0)
 +
 +#pressiona 's' para salvar o arquivo
 if k == ord("s"): if k == ord("s"):
 +#funcao cv:imwrite salva o objeto cv:Mat como png
    cv.imwrite("starry_night.png", img)    cv.imwrite("starry_night.png", img)
 </file> </file>
  
 +Utilize a imagem abaixo para o teste:
 +\\
 +{{:starry_night.jpg?50|}}
  
 +
 +==== imread() ====
 +
 +Python:
 +cv.imread( filename[, flags] ) -> retva
 +
 +=== filename ===
 +
 +Formatos suportados:
 +  * 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)
 +  * AVIF - *.avif (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)
 +
 +=== flags (não obrigatório) ===
 +  * cv.IMREAD_UNCHANGED
 +  * cv.IMREAD_GRAYSCALE
 +  * **cv.IMREAD_COLOR - PADRÂO**
 +  * cv.IMREAD_ANYDEPTH
 +  * cv.IMREAD_ANYCOLOR
 +  * cv.IMREAD_LOAD_GDAL
 +  * cv.IMREAD_REDUCED_GRAYSCALE_2
 +  * cv.IMREAD_REDUCED_COLOR_2
 +  * cv.IMREAD_REDUCED_GRAYSCALE_4
 +  * cv.IMREAD_IGNORE_ORIENTATION 
  
 Referências: Referências:
Linha 33: Linha 80:
  
 [[https://docs.opencv.org/4.x/d6/d00/tutorial_py_root.html|OpenCV-Python Tutorials]] [[https://docs.opencv.org/4.x/d6/d00/tutorial_py_root.html|OpenCV-Python Tutorials]]
 +
 +[[https://docs.opencv.org/4.x/db/deb/tutorial_display_image.html| Started with Images]]
opencv.1688787617.txt.gz · Última modificação: 2023/07/08 00:40 por jdos

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki