StereoRetinaI.C
00001 #include "Robots/RobotBrain/StereoRetinaI.H"
00002
00003
00004 StereoRetinaI::StereoRetinaI(int id, OptionManager& mgr,
00005 const std::string& descrName, const std::string& tagName) :
00006 RobotBrainComponent(mgr, descrName, tagName),
00007 itsRunning(true)
00008 {
00009 }
00010
00011
00012 StereoRetinaI::~StereoRetinaI()
00013 {
00014 }
00015
00016 void StereoRetinaI::registerTopics()
00017 {
00018 LINFO("Registering Retina Message");
00019 this->registerPublisher("RetinaMessageTopic");
00020 }
00021
00022 void StereoRetinaI::evolve()
00023 {
00024 if (camera) {
00025
00026
00027
00028 Image<byte> monoImage = camera->getImage();
00029 Image<PixRGB<byte> > colorImage = deBayer(monoImage, BAYER_RGGB);
00030 Image<PixRGB<byte> > scaledImage = rescaleNI(colorImage, colorImage.getWidth()/2, colorImage.getHeight()/2);
00031 RobotSimEvents::RetinaMessagePtr msg = new RobotSimEvents::RetinaMessage;
00032 msg->img = Image2Ice(scaledImage);
00033
00034 if (itsIceIdentity.getVal() == "LFwdCamera") msg->cameraID = "LFwdCamera";
00035 else if (itsIceIdentity.getVal() == "RFwdCamera") msg->cameraID = "RFwdCamera";
00036 else if (itsIceIdentity.getVal() == "LDownCamera") msg->cameraID = "LDownCamera";
00037 else if (itsIceIdentity.getVal() == "RDownCamera") msg->cameraID = "RDownCamera";
00038 else msg->cameraID = "Unknown";
00039
00040 this->publish("RetinaMessageTopic", msg);
00041 } else {
00042
00043 std::vector<uint64_t> list = cameraManager.getCameraList();
00044
00045 if (list.size() > 0 && itsIceIdentity.getVal() == "LFwdCamera") {
00046 camera = cameraManager.getCamera(list[0]);
00047 } else if (list.size() > 1 && itsIceIdentity.getVal() == "RFwdCamera") {
00048 camera = cameraManager.getCamera(list[1]);
00049 } else if (list.size() > 2 && itsIceIdentity.getVal() == "LDownCamera") {
00050 camera = cameraManager.getCamera(list[2]);
00051 } else if (list.size() > 3 && itsIceIdentity.getVal() == "RDownCamera") {
00052 camera = cameraManager.getCamera(list[3]);
00053 }
00054 printf("Cameras Detected: %d\n", list.size());
00055 }
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 }
00073
00074
00075 void StereoRetinaI::updateMessage(const RobotSimEvents::EventMessagePtr& eMsg,
00076 const Ice::Current&)
00077 {
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 }
00092
00093