2

我已经运行了这段代码,它给了我与黑色图像相同的图像,而不是标记的 ROI 图像。

public class ROITest {
 private static final String OUT_FILE = "img\\ROI.jpg";
 public static void main(String[] args)
  {
       opencv_core.CvRect r =new opencv_core.CvRect();
       args[0]="img\\2.jpg";
    if (args.length != 1) {
      System.out.println("Usage: run FaceDetection <input-file>");
      return;
    }
    // preload the opencv_objdetect module to work around a known bug
   // Loader.load(opencv_objdetect.class);
    Loader.load(opencv_core.class);
    // load an image
    System.out.println("Loading image from " + args[0]);
    IplImage origImg = cvLoadImage(args[0]);
  // IplImage ROIimg =  CvSetImageROI(origImg, opencv_core.cvRect(0, 0, 640, 480));
  cvSetImageROI(origImg, cvRect(4,4, origImg.width(), origImg.height()));
  IplImage ROIimg = IplImage.create(origImg.width(), origImg.height(),origImg.depth(), origImg.nChannels());
 cvCopy(ROIimg,origImg);
  cvSaveImage(OUT_FILE, origImg);  
  final IplImage image = cvLoadImage(OUT_FILE);
  CanvasFrame canvas = new CanvasFrame("Region of Interest");
  cvResetImageROI(image);
  canvas.showImage(image);
  canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}
}

它给出了像......这样的错误

Loading image from img\2.jpg
 OpenCV Error: Assertion failed (src.depth() == dst.depth() && src.size == dst.size) in unknown 
function, file ..\..\..\src\opencv\modules\core\src\copy.cpp, line 557
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (0xe06d7363), pid=5828, tid=6652
#
# JRE version: 6.0_18-b07
# Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode windows-x86 )
# Problematic frame:
# C  [KERNELBASE.dll+0xb9bc]
# An error report file with more information is saved as:
# C:\UWU_EX_09_0309_universityProject\test\hs_err_pid5828.log
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.

请您考虑一下这个问题...我在这里坚持我的项目...

4

0 回答 0