Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.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
C++ opencv零点矩阵在每次迭代的三个位置上给出255_C++_Opencv_Image Processing - Fatal编程技术网

C++ opencv零点矩阵在每次迭代的三个位置上给出255

C++ opencv零点矩阵在每次迭代的三个位置上给出255,c++,opencv,image-processing,C++,Opencv,Image Processing,这是我关于堆栈概述的第一篇文章,所以请对我温柔:) 我是opencv的新手,我尝试制作一个游戏,在这个游戏中,每当我的手碰到其中一个圆形时,我都要创建两个圆形,我会向上或向下计算分数。 我已经从皮肤检测改为目标检测 我在HSV的3个通道上用阈值对某种颜色进行了校准。 代码总是在球的位置上给我零,除非我定义的对象通过该位置。 我的问题是当代码应该为零时,它总是返回三个255值。 每个循环都必须有3次。 谢谢这是我的密码 #include < windows.h > #inclu

这是我关于堆栈概述的第一篇文章,所以请对我温柔:) 我是opencv的新手,我尝试制作一个游戏,在这个游戏中,每当我的手碰到其中一个圆形时,我都要创建两个圆形,我会向上或向下计算分数。 我已经从皮肤检测改为目标检测 我在HSV的3个通道上用阈值对某种颜色进行了校准。 代码总是在球的位置上给我零,除非我定义的对象通过该位置。 我的问题是当代码应该为零时,它总是返回三个255值。 每个循环都必须有3次。 谢谢这是我的密码

    #include < windows.h >
#include <highgui.h>
#include <cxcore.h>
#include <cv.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include<time.h>

using namespace std; 

using namespace cv;

int main() 

{
VideoCapture cap(0);

Mat frame,frames,frame1[3],newone,thresholded,thresholded1,thresholded2;

int scoreUpDown=0;

for(;;){

   Redo:int a=rand()%550;

        int b=abs(a-120);

        if(abs(a-b)<=25)goto Redo;

cap>>frame;

for(int i=0;i<= frame.rows-10;i=i+10)

{

cap>>frame;

flip(frame,frame,1);

cvtColor(frame,frames,CV_RGB2HSV);

split(frames,frame1);

threshold(frame1[0], thresholded, 42, 112, THRESH_BINARY);

threshold(thresholded, thresholded, 0, 255, THRESH_BINARY);

bitwise_not(thresholded,thresholded);

threshold(frame1[1], thresholded1, 87, 163, THRESH_BINARY);

threshold(thresholded1, thresholded1, 0, 255, THRESH_BINARY);

threshold(frame1[2], thresholded2, 145, 260, THRESH_BINARY);

threshold(thresholded2, thresholded2, 0, 255, THRESH_BINARY);

bitwise_and(thresholded,thresholded1,newone);

bitwise_and(newone,thresholded2,newone);

// GaussianBlur( newone, newone, Size( 7, 7 ), 0, 0 );

circle( newone, Point(a , i), 22, Scalar( 255, 0, 0 ), -5, 15,2 );

circle( newone, Point(b , i), 22, Scalar( 255, 0 , 0 ), -5, 15,2 );

circle( frames, Point(a , i), 22, Scalar( 0, 0, 255 ), -5, 15,2 );

circle( frames, Point(b , i), 22, Scalar( 0, 255 , 0 ), -5, 15,2 );

line( frames, Point( 0, 410 ), Point(640,410), Scalar( 255, 255, 255 ),  5, 10 );

putText(frames,"STARAT",Point(5,450),2,1,CV_RGB(255, 255, 0),4,8,false);    

putText(frames,"END",Point(550,450),2,1,CV_RGB(255, 255, 0),4,8,false); 

putText(frames,"SCORE",Point(250,450),2,1,CV_RGB(255, 255, 0),4,8,false);

stringstream ss;

                ss<<scoreUpDown;

                string txt=ss.str();

                Point textPos(100,50);

                putText(frames,txt,Point(400,450),2,1,CV_RGB(255, 0, 
0),4,8,false);

int u=newone.at<uchar>(a,i);

int m=newone.at<uchar>(b,i);

int s=frames.at<uchar>(a,i);

int z=newone.at<uchar>(b,i);

if(u==255)

    scoreUpDown=scoreUpDown+10;

if(m==255)

    scoreUpDown=scoreUpDown-10;

cout<<"u= "<<u;

cout<<"   m= "<<m;

cout<<"   s= "<<s<<endl;

cvtColor(newone,newone,CV_HSV2RGB);

imshow("HSV",frames);

imshow("new",newone);

if(waitKey(60)==99)break;  

}
}

return 0; 

}
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
使用名称空间cv;
int main()
{
视频捕获上限(0);
垫框,框,框1[3],新框,阈值化,阈值化1,阈值化2;
int scoreUpDown=0;
对于(;;){
重做:int a=rand()%550;
int b=abs(a-120);
如果(abs(a-b)>车架;
对于(int i=0;i>frame;
翻转(帧,帧,1);
CVT颜色(框架、框架、CV_RGB2HSV);
拆分(帧,帧1);
阈值(帧1[0],阈值化,42,112,阈值二进制);
阈值(阈值化,阈值化,0,255,阈值二进制);
按位_非(阈值化,阈值化);
阈值(frame1[1],阈值为1,87,163,阈值为二进制);
阈值(thresholded1,thresholded1,0,255,threshold_二进制);
阈值(frame1[2],阈值2,145,260,阈值二进制);
阈值(thresholded2,thresholded2,0,255,threshold_二进制);
按位_和(阈值化、阈值化1、新值);
按位_和(新一个,阈值2,新一个);
//GaussianBlur(newone,newone,Size(7,7),0,0);
圆(newone,点(a,i),22,标量(255,0,0),-5,15,2);
圆(newone,点(b,i),22,标量(255,0,0),-5,15,2);
圆(帧,点(a,i),22,标量(0,0,255),-5,15,2);
圆(帧,点(b,i),22,标量(0,255,0),-5,15,2);
线(帧、点(0410)、点(640410)、标量(255、255、255)、5、10);
putText(帧,“起始”,点(5450),2,1,CV_RGB(255,255,0),4,8,假);
putText(帧,“结束”,点(550450),2,1,CV_RGB(255,255,0),4,8,假);
putText(帧,“分数”,点(250450),2,1,CV_RGB(255,255,0),4,8,假);
细流ss;

ssIs
abs(a-bI不知道规格,但你确定
iah是的,谢谢。但这不是主要问题,我正在寻找答案。是的,我认为它不正确,但它工作正常。谢谢你的通知。我已经在我的代码中接受了它,我会更正它。还有其他帮助吗??