Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Java+OpenCV to realize the function of taking pictures

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to use Java+OpenCV to achieve photo function", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use Java+OpenCV to take pictures.

Rely on the jar package: there is only one jar package for OpenCv, which can be downloaded directly from the official website

The following is the code

Import java.awt.Graphics;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.awt.image.BufferedImage;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.WindowConstants;import org.opencv.core.Core;import org.opencv.core.Mat;import org.opencv.imgcodecs.Imgcodecs;import org.opencv.imgproc.Imgproc;import org.opencv.videoio.VideoCapture;import org.opencv.videoio.Videoio;public class CaptureBasic extends JPanel {undefined private static BufferedImage mImg; private static VideoCapture capture Private static Mat capImg; private BufferedImage mat2BI (Mat mat) {undefined int dataSize = mat.cols () * mat.rows () * (int) mat.elemSize (); byte [] data=new byte [dataSize]; mat.get (0,0heroin data); int type=mat.channels () = = 1? BufferedImage.TYPE_BYTE_GRAY:BufferedImage.TYPE_3BYTE_BGR; if (type==BufferedImage.TYPE_3BYTE_BGR) {undefined for (int itemo witi)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report