org.opencv.core.Core.flip()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(433)

本文整理了Java中org.opencv.core.Core.flip()方法的一些代码示例,展示了Core.flip()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Core.flip()方法的具体详情如下:
包路径:org.opencv.core.Core
类名称:Core
方法名:flip

Core.flip介绍

[英]Flips a 2D array around vertical, horizontal, or both axes.

The function flip flips the array in one of three different ways (row and column indices are 0-based):

dst _(ij) =<BR>

The example scenarios of using the function are the following:

  • Vertical flipping of the image (flipCode == 0) to switch between top-left and bottom-left image origin. This is a typical operation in video processing on Microsoft Windows* OS.
  • Horizontal flipping of the image with the subsequent horizontal shift and absolute difference calculation to check for a vertical-axis symmetry (flipCode > 0).
  • Simultaneous horizontal and vertical flipping of the image with the subsequent shift and absolute difference calculation to check for a central symmetry (flipCode < 0).
  • Reversing the order of point arrays (flipCode > 0 or flipCode == 0).
    [中]围绕垂直、水平或两个轴翻转二维阵列。
    函数flip以三种不同方式之一翻转数组(行和列索引基于0):
    dst_uj(ij)=<BR>
    使用该功能的示例场景如下:
    垂直翻转图像(flipCode == 0)以在左上角和左下角图像原点之间切换。这是Microsoft Windows操作系统上视频处理的典型操作。
    *水平翻转图像,随后进行水平移动和绝对差计算,以检查垂直轴对称性(flipCode > 0)。
    *同时水平和垂直翻转图像,随后进行移位和绝对差计算,以检查中心对称性(flipCode < 0)。
    *颠倒点阵列的顺序(flipCode > 0flipCode == 0)。

代码示例

代码示例来源:origin: ytai/IOIOPlotter

  1. private static void rotateCCW(Mat mat) {
  2. Core.transpose(mat, mat);
  3. Core.flip(mat, mat, 0);
  4. }

代码示例来源:origin: nroduit/Weasis

  1. public static ImageCV flip(Mat source, int flipCvType) {
  2. if (flipCvType < 0) {
  3. return ImageCV.toImageCV(source);
  4. }
  5. Objects.requireNonNull(source);
  6. ImageCV dstImg = new ImageCV();
  7. Core.flip(source, dstImg, flipCvType);
  8. return dstImg;
  9. }

代码示例来源:origin: ytai/IOIOPlotter

  1. Core.flip(srcImage_, srcImage_, 1);

代码示例来源:origin: ytai/IOIOPlotter

  1. Core.flip(srcImage_, edgesImage_, 1);
  2. } else {
  3. srcImage_.copyTo(edgesImage_);

代码示例来源:origin: Qualeams/Android-Face-Recognition-with-Deep-Learning-Test-Framework

  1. Core.flip(imgRgba,imgRgba,1);

代码示例来源:origin: Qualeams/Android-Face-Recognition-with-Deep-Learning-Test-Framework

  1. public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
  2. Mat imgRgba = inputFrame.rgba();
  3. Mat img = new Mat();
  4. imgRgba.copyTo(img);
  5. List<Mat> images = ppF.getProcessedImage(img, PreProcessorFactory.PreprocessingMode.RECOGNITION);
  6. Rect[] faces = ppF.getFacesForRecognition();
  7. // Selfie / Mirror mode
  8. if(front_camera){
  9. Core.flip(imgRgba,imgRgba,1);
  10. }
  11. if(images == null || images.size() == 0 || faces == null || faces.length == 0 || ! (images.size() == faces.length)){
  12. // skip
  13. return imgRgba;
  14. } else {
  15. faces = MatOperation.rotateFaces(imgRgba, faces, ppF.getAngleForRecognition());
  16. for(int i = 0; i<faces.length; i++){
  17. MatOperation.drawRectangleAndLabelOnPreview(imgRgba, faces[i], rec.recognize(images.get(i), ""), front_camera);
  18. }
  19. return imgRgba;
  20. }
  21. }

代码示例来源:origin: Qualeams/Android-Face-Recognition-with-Deep-Learning-Test-Framework

  1. @Override
  2. public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) {
  3. Mat imgRgba = inputFrame.rgba();
  4. Mat img = new Mat();
  5. imgRgba.copyTo(img);
  6. List<Mat> images = ppF.getCroppedImage(img);
  7. Rect[] faces = ppF.getFacesForRecognition();
  8. // Selfie / Mirror mode
  9. if(front_camera){
  10. Core.flip(imgRgba,imgRgba,1);
  11. }
  12. if(images == null || images.size() == 0 || faces == null || faces.length == 0 || ! (images.size() == faces.length)){
  13. // skip
  14. return imgRgba;
  15. } else {
  16. faces = MatOperation.rotateFaces(imgRgba, faces, ppF.getAngleForRecognition());
  17. for(int i = 0; i<faces.length; i++){
  18. MatOperation.drawRectangleAndLabelOnPreview(imgRgba, faces[i], "", front_camera);
  19. }
  20. return imgRgba;
  21. }
  22. }

代码示例来源:origin: openpnp/openpnp

  1. Core.flip(timage.t(), timage, 1);

代码示例来源:origin: openpnp/openpnp

  1. protected BufferedImage transformImage(BufferedImage image) {
  2. Mat mat = OpenCvUtils.toMat(image);
  3. mat = crop(mat);
  4. mat = calibrate(mat);
  5. mat = undistort(mat);
  6. // apply affine transformations
  7. mat = scale(mat, scaleWidth, scaleHeight);
  8. mat = rotate(mat, rotation);
  9. mat = offset(mat, offsetX, offsetY);
  10. mat = deinterlace(mat);
  11. if (flipX || flipY) {
  12. int flipCode;
  13. if (flipX && flipY) {
  14. flipCode = -1;
  15. }
  16. else {
  17. flipCode = flipX ? 0 : 1;
  18. }
  19. Core.flip(mat, mat, flipCode);
  20. }
  21. image = OpenCvUtils.toBufferedImage(mat);
  22. mat.release();
  23. return image;
  24. }

相关文章

Core类方法