Sunday, 15 September 2013

convert the original image to ROI marked image

convert the original image to ROI marked image

I have run this code and it gives me the same image as the black image
instead of the marked ROI image..
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);
}
}
It gives error like .....
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.
Can You please consider about this matter please...I am stuck with my
project here...

No comments:

Post a Comment