Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenCV拍摄奇怪的照片-Java_Java_Opencv - Fatal编程技术网

OpenCV拍摄奇怪的照片-Java

OpenCV拍摄奇怪的照片-Java,java,opencv,Java,Opencv,我头痛,似乎无法解决这个问题。我正在做的是,我有一台计算机也连接在一起的机器,当一个条件为真时,它会拍一张照片。但问题是当它确实拍了一张照片时,它有时会很奇怪,下面的视图。我试着把画面颠倒过来,但并不是所有的东西都倒过来了。我到处找。。。什么也帮不了我。我尝试了许多不同的示例代码,它们要么不起作用,要么仍然存在此问题 正常图片: 奇怪的图片: 下面是设置相机的焦距、变焦、亮度等设置 public void setCameraValues() { this.camera.set(28,

我头痛,似乎无法解决这个问题。我正在做的是,我有一台计算机也连接在一起的机器,当一个条件为真时,它会拍一张照片。但问题是当它确实拍了一张照片时,它有时会很奇怪,下面的视图。我试着把画面颠倒过来,但并不是所有的东西都倒过来了。我到处找。。。什么也帮不了我。我尝试了许多不同的示例代码,它们要么不起作用,要么仍然存在此问题

正常图片:

奇怪的图片:

下面是设置相机的焦距、变焦、亮度等设置

public void setCameraValues()
{
    this.camera.set(28, ((Integer)this.values.get(0)).intValue());
    this.camera.set(27, ((Integer)this.values.get(1)).intValue());
    this.camera.set(10, ((Integer)this.values.get(2)).intValue());
    this.camera.set(11, ((Integer)this.values.get(3)).intValue());
    this.camera.set(12, ((Integer)this.values.get(4)).intValue());
    this.camera.set(15, ((Integer)this.values.get(5)).intValue());
    this.camera.set(20, ((Integer)this.values.get(6)).intValue());
    this.camera.set(33, ((Integer)this.values.get(7)).intValue());
    this.camera.set(34, ((Integer)this.values.get(8)).intValue());
    this.camera.set(3, ((Integer)this.values.get(9)).intValue());
    this.camera.set(4, ((Integer)this.values.get(10)).intValue());
}
编辑:
我使用的网络摄像头是Microsoft LifeCam HD

看起来颜色颠倒了吗?我试过反转奇怪的图片,它与正常图片不太接近。你玩过颜色空间吗?例如,从HSV到BGR的cv::CVT颜色。所以你说这只是有时候很奇怪?也许这更像是你相机的硬件问题?也许你的相机在激活后需要一段时间,直到测量出正确的图像?我在不同的摄像机上看到过。也许每次拍摄后都不要松开相机。如果这解决了问题,你也许可以解决这个问题。我有另一个想法:两个线程是否会同时运行?当两个线程同时读取图像时,可能会出现问题,或者如果其中一个线程设置了参数,而另一个线程读取图像,则更可能出现问题??请尝试在函数开始时添加互斥锁,并在函数结束时解锁!!!
public void setCameraValues()
{
    this.camera.set(28, ((Integer)this.values.get(0)).intValue());
    this.camera.set(27, ((Integer)this.values.get(1)).intValue());
    this.camera.set(10, ((Integer)this.values.get(2)).intValue());
    this.camera.set(11, ((Integer)this.values.get(3)).intValue());
    this.camera.set(12, ((Integer)this.values.get(4)).intValue());
    this.camera.set(15, ((Integer)this.values.get(5)).intValue());
    this.camera.set(20, ((Integer)this.values.get(6)).intValue());
    this.camera.set(33, ((Integer)this.values.get(7)).intValue());
    this.camera.set(34, ((Integer)this.values.get(8)).intValue());
    this.camera.set(3, ((Integer)this.values.get(9)).intValue());
    this.camera.set(4, ((Integer)this.values.get(10)).intValue());
}