ethzasl_ptam icon indicating copy to clipboard operation
ethzasl_ptam copied to clipboard

RGB video source problem

Open Reena24 opened this issue 10 years ago • 3 comments

Hi the PTAMM code started to work finally in Windows7 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; gray

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_& frame_p = (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<Rgb > &imRGB){ Mat clone = frame.clone(); Mat_& frame_p = (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<Rgb > &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 to get RGB type or a coloured video Input Source

Reena24 avatar Apr 07 '14 04:04 Reena24

please direct your question to http://ewokrampage.wordpress.com/

ethzasl_ptam is a modified version of PTAM (not PTAMM) and is ROS-based. There is currently no support for video_source input nor Windows.

Best, Stephan


From: Reena24 [[email protected]] Sent: Sunday, April 06, 2014 9:31 PM To: ethz-asl/ethzasl_ptam Subject: [ethzasl_ptam] RGB video source problem (#31)

Hi the PTAMM code started to work finally in Windows7 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_& frame_p = (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_& frame_p = (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 to get RGB type video Input Source Could Someone please tell me

— Reply to this email directly or view it on GitHubhttps://github.com/ethz-asl/ethzasl_ptam/issues/31.

stephanweiss avatar Apr 07 '14 15:04 stephanweiss

Ok could you just tell me this like what are the changes added to the ethzasl_ptam and also if I wanted to save the keyframes as colored images where I would make the changes in PTAM

Reena24 avatar Apr 07 '14 17:04 Reena24

The changes were numerous. A good overview gives our recent JFR paper: "Monocular Vision for Long-term Micro Aerial Vehicle State Estimation: A Compendium" http://onlinelibrary.wiley.com/doi/10.1002/rob.21466/pdf

To save the keyframes you might want to have a lookt at sysem.cc. Also, you could have a look at the ptam_visualizer node - we already publish some information via that node in rviz.

Best, Stephan


From: Reena24 [[email protected]] Sent: Monday, April 07, 2014 10:19 AM To: ethz-asl/ethzasl_ptam Cc: Stephan Weiss Subject: Re: [ethzasl_ptam] RGB video source problem (#31)

Ok could you just tell me this like what are the changes added to the ethzasl_ptam and also if I wanted to save the keyframes as colored images where I would make the changes in PTAM

— Reply to this email directly or view it on GitHubhttps://github.com/ethz-asl/ethzasl_ptam/issues/31#issuecomment-39757728.

stephanweiss avatar Apr 07 '14 19:04 stephanweiss