Hi the PTAMM code started to work finally in Windows and I was finally able to get the video source from usb web cam using the code
include “VideoSource.h”
//#include
include
include
include
include
include
include
using namespace CVD;
using namespace std;
using namespace GVars3;
using namespace cv;
define OPENCV_VIDEO_W 640
define OPENCV_VIDEO_H 480
namespace PTAMM
{
VideoSource::VideoSource()
{
cout << " VideoSource_Linux: Opening video source…" <isOpened()){
cerr << "Unable to get the camera" << endl;
exit(-1);
}
cout << " … got video source." << endl;
mirSize = ImageRef(OPENCV_VIDEO_W, OPENCV_VIDEO_H);
};
ImageRef VideoSource::Size()
{
return mirSize;
};
void conversionNB(Mat frame, Image &imBW){
Mat clone = frame.clone();
Mat_& framep = (Mat&)clone;
for (int i = 0; i < OPENCV_VIDEO_H; i++){
for (int j = 0; j < OPENCV_VIDEO_W; j++){
imBW[i][j] = (frame_p(i,j)[0] + frame_p(i,j)[1] + frame_p(i,j)[2]) / 3;
}
}
}
void conversionRGB(Mat frame, Image &imRGB){
Mat clone = frame.clone();
Mat_& framep = (Mat&)clone;
for (int i = 0; i < OPENCV_VIDEO_H; i++){
for (int j = 0; j < OPENCV_VIDEO_W; j++){
imRGB[i][j].red = frame_p(i,j)[2];
imRGB[i][j].green = frame_p(i,j)[1];
imRGB[i][j].blue = frame_p(i,j)[0];
}
}
}
void VideoSource::GetAndFillFrameBWandRGB(Image &imBW, Image &imRGB)
{
Mat frame;
VideoCapture* cap = (VideoCapture)mptr;
cap >> frame;
conversionNB(frame, imBW);
conversionRGB(frame, imRGB);
}
}
But the video source for PTAMM is black and white how do I get the an RGB video source instead of a gray image as video source. I think I need to add the line cvCvtColor(&frame,&frame,CV_GRAY2BGR);
but it dosnt work cause I get OpenCV assertion error. Could someone tell me how do I get RGB type video Input Source.
Hi the PTAMM code started to work finally in Windows and I was finally able to get the video source from usb web cam using the code
include “VideoSource.h”
//#include
include
include
include
include
include
include
using namespace CVD; using namespace std; using namespace GVars3; using namespace cv;
define OPENCV_VIDEO_W 640
define OPENCV_VIDEO_H 480
namespace PTAMM { VideoSource::VideoSource() { cout << " VideoSource_Linux: Opening video source…" <isOpened()){ cerr << "Unable to get the camera" << endl; exit(-1); } cout << " … got video source." << endl; mirSize = ImageRef(OPENCV_VIDEO_W, OPENCV_VIDEO_H); };
ImageRef VideoSource::Size() { return mirSize; };
void conversionNB(Mat frame, Image &imBW){ Mat clone = frame.clone(); Mat_& framep = (Mat&)clone; for (int i = 0; i < OPENCV_VIDEO_H; i++){ for (int j = 0; j < OPENCV_VIDEO_W; j++){ imBW[i][j] = (frame_p(i,j)[0] + frame_p(i,j)[1] + frame_p(i,j)[2]) / 3; } }
}
void conversionRGB(Mat frame, Image &imRGB){
Mat clone = frame.clone();
Mat_& framep = (Mat&)clone;
for (int i = 0; i < OPENCV_VIDEO_H; i++){
for (int j = 0; j < OPENCV_VIDEO_W; j++){
imRGB[i][j].red = frame_p(i,j)[2];
imRGB[i][j].green = frame_p(i,j)[1];
imRGB[i][j].blue = frame_p(i,j)[0];
}
}
}
void VideoSource::GetAndFillFrameBWandRGB(Image &imBW, Image &imRGB)
{
Mat frame;
VideoCapture* cap = (VideoCapture)mptr;
cap >> frame;
conversionNB(frame, imBW);
conversionRGB(frame, imRGB);
}
}
But the video source for PTAMM is black and white how do I get the an RGB video source instead of a gray image as video source. I think I need to add the line cvCvtColor(&frame,&frame,CV_GRAY2BGR);
but it dosnt work cause I get OpenCV assertion error. Could someone tell me how do I get RGB type video Input Source.