Logitech webcam pink/purple color

hi there,

I just connected 2 logitech camera’s to my computer (webcam, logitch quickcam chat) but the color of the frames I grab is a bit pink / purple…
I tested this on another computer and it worked fine.

Does someone knows more about this?

Ahh… found it… I used ofSetColor()… <---- is this a bug in of?

  
  
#include "CamInput.h"  
  
CamInput::CamInput(std::string sID, int iDeviceID, int iWidth, int iHeight) {  
	cout << "Created CamInput: " << sID << "\n";  
    SetID(sID);  
    _miWidth = iWidth;  
    _miHeight = iHeight;  
  
    _mGrabber.setVerbose(true);  
    _mGrabber.setDeviceID(iDeviceID);  
    _mGrabber.initGrabber(_miWidth,_miHeight);  
    _mGrabber.listDevices();  
  
    // Load the font from the data directory  
    _mIDFont.loadFont("fonts/idfont.ttf",32);  
}  
std::string CamInput::GetID() {  
    return _msID;  
}  
  
void CamInput::SetID(std::string sID) {  
    _msID = sID;  
}  
  
bool CamInput::SaveFrameToFile(std::string sFile) {  
    std::cout << "Saving to a file: " << sFile << "\n";  
  
	unsigned char* p_bytes = GetPixels();  
	ofImage o_image;  
  
	o_image.setFromPixels(p_bytes, _miWidth, _miHeight,OF_IMAGE_COLOR, true);  
	o_image.saveImage(sFile.c_str());  
	std::cout << "@ Saved file: " << sFile << "\n";  
    return true;  
}  
void CamInput::Update() {  
	GrabFrame();  
}  
void CamInput::Draw(int iX, int iY) {  
	_mGrabber.draw(iX, iY);  
	//ofSetColor(0xFF00FF);  
	float f_height = _mIDFont.stringHeight(GetID().c_str());  
	_mIDFont.drawString(GetID().c_str(), iX + 10, iY + _miHeight +f_height+5);  
}  
  
void CamInput::GrabFrame() {  
 	_mGrabber.grabFrame();  
}  
unsigned char * CamInput::GetPixels() {  
	return _mGrabber.getPixels();  
}  
  

ofSetColor()… <---- is this a bug in of?

no, this is a feature :slight_smile:

when you draw a texture current draw color tints the texture. since the videoGrabber, videoPlayer, etc have texture internally, the color you use before you draw them effects them. just set the color ofSetColor(255,255,255) before you draw the object / item and you’ll be fine.

take care!
zach