简体   繁体   English

人脸检测后JavaCV工作/写入BufferdImage

[英]JavaCV working/writing to BufferdImage after face detection

I am successfully detecting faces using JavaCV, it's not totally accurate but good enough for the moment. 我已经使用JavaCV成功检测到人脸,虽然目前尚不完全准确,但已经足够好了。

However, for testing purposes and with a look at the future (this is only part of a bigger group project), I want to write rectangles onto the faces using BufferedImage and Graphics.drawRect(). 但是,出于测试目的和对未来的展望(这只是更大的团队项目的一部分),我想使用BufferedImage和Graphics.drawRect()将矩形写到面上。

I am aware of the fact that you can draw rects to faces using JavaCV with the static methods, but it's not what I need / want to do. 我知道一个事实,您可以使用带有静态方法的JavaCV来绘制矩形,但这不是我需要/不想做的。 If I, after the scanning process, try to load the image using ImageIO and try to write rects to it, the application ends with a native error. 如果我在扫描过程之后,尝试使用ImageIO加载图像并尝试向其写入rect,则该应用程序将以本机错误结束。

Is there any way I can command openCV to "release" the image (because I think that's the soruce of the problem, that opencv does not release the image file.) ? 有什么方法可以命令openCV“释放”映像(因为我认为这是问题的根源,opencv不会释放映像文件。)?

Thanks in advance 提前致谢

edit: error code: 编辑:错误代码:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fc705dafac4, pid=8216, tid=140493568964352
#
# JRE version: 7.0_21-b02
# Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libjpeg.so.8+0x1eac4]  jpeg_save_markers+0x84

edit: 编辑:

 cvReleaseImage(inputImage);
            cvReleaseImage(grayImage);
            cvClearMemStorage(storage);

didnt help too 也没有帮助

You can draw simple rectangles without Graphics.drawRect(); 您可以不使用Graphics.drawRect();绘制简单的矩形。 Theres a nice way to set pixels of a BufferedImage in java. 有一种在Java中设置BufferedImage像素的好方法。

try { BufferedImage img = ImageIO.read(new File("img.png")); int x, y; int width, hight; Color color = Color.black; y = 50; x = 50; width = 90; hight = 90; for(int i=x;i<=width;i++){ img.setRGB(i, y, color.getRGB()); img.setRGB(i, hight, color.getRGB()); for(int i=y;i<=hight;i++){ img.setRGB(x, i, color.getRGB()); img.setRGB(width, i, color.getRGB()); } g.drawImage(img, 0, 0, this); } catch (IOException e) { System.err.println("!!!IOException!!!"); }

I hope this will help. 我希望这将有所帮助。

NoName 无名

Check your operating system running , and install 64-bit opencv if your lap is running on 64 bit OS. 检查您的操作系统是否正在运行,如果您的膝上计算机在64位OS上运行,请安装64位opencv。 This link may help you a lot 此链接可能对您有很大帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM