Green screen when webcam comes up

asked 2015-05-18 11:41:15 -0600

Hi guys im very new to opencv and visual studio so ive just been running other peoples code to test and see what its all about anyway ive tested a few but all of them if the program starts and the camera feed comes up its green I can still see myself slightly if I move but ye its not right.

Any idea please? here is the code im trying at the moment:

//objectTrackingTutorial.cpp

//Written by Kyle Hounslow 2013

//Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software") //, to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, //and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

//The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS //IN THE SOFTWARE.

//*AREAS MARKED WITH ASTERISKS MODIFIED BY MARIA RAMOS //*DECEMBER 2014

define _CRT_SECURE_NO_DEPRECATE

include <sstream>

include <string>

include <iostream>

include <opencv\highgui.h>

include <opencv\cv.h>

include <chrono>

include <thread>

using namespace cv; //initial min and max HSV filter values. //these will be changed using trackbars int H_MIN = 0; int H_MAX = 256; int S_MIN = 0; int S_MAX = 256; int V_MIN = 0; int V_MAX = 256; //default capture width and height const int FRAME_WIDTH = 640; const int FRAME_HEIGHT = 480; //max number of objects to be detected in frame const int MAX_NUM_OBJECTS = 50; //minimum and maximum object area const int MIN_OBJECT_AREA = 20 * 20; const int MAX_OBJECT_AREA = FRAME_HEIGHTFRAME_WIDTH / 1.5; //names that will appear at the top of each window const string windowName = "Original Image"; const string windowName1 = "HSV Image"; const string windowName2 = "Thresholded Image"; const string windowName3 = "After Morphological Operations"; const string trackbarWindowName = "Trackbars"; void on_trackbar(int, void) {//This function gets called whenever a // trackbar position is changed

} string intToString(int number){

std::stringstream ss;
ss << number;
return ss.str();

} void createTrackbars(){ //create window for trackbars

namedWindow(trackbarWindowName, 0);
//create memory to store trackbar name on window
char TrackbarName[50];
sprintf(TrackbarName, "H_MIN", H_MIN);
sprintf(TrackbarName, "H_MAX", H_MAX);
sprintf(TrackbarName, "S_MIN", S_MIN);
sprintf(TrackbarName, "S_MAX", S_MAX);
sprintf(TrackbarName, "V_MIN", V_MIN);
sprintf(TrackbarName, "V_MAX", V_MAX);
//create trackbars and insert them into window
//3 parameters are: the address of the variable that is changing when the trackbar is moved(eg.H_LOW),
//the max value the trackbar can move (eg. H_HIGH), 
//and the function that is called whenever the trackbar is moved ...
(more)
edit retag flag offensive close merge delete

Comments

hope you don't mind me deleting your duplicate question

berak gravatar imageberak ( 2015-05-18 12:10:14 -0600 )edit

do you really expect us to debug this wall of ill-formatted code?

berak gravatar imageberak ( 2015-05-18 12:14:33 -0600 )edit

No not at all thanks for doing that.

As for the code I didnt know its badly formatted as I said I basicly started today with this anyway I doubt its the code because ive tried a whole bunch of code which all work except the fact the webcam screen is green but the program still works and my webcam works fine.

Undermentioned gravatar imageUndermentioned ( 2015-05-18 12:28:34 -0600 )edit