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 /*ImageIceMod::ImageIce rawImage = camera->getIceImage(); 00026 Image<byte> monoImage = Ice2Image<byte>(rawImage); 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 /*for (std::vector<Camera*>::size_type i = 0; i < cameras.size(); i++) { 00057 ImageIceMod::ImageIce rawImage = cameras[i]->getIceImage(); 00058 Image<byte> monoImage = Ice2Image<byte>(rawImage); 00059 Image<PixRGB<byte> > colorImage = deBayer(monoImage, BAYER_RGGB); 00060 Image<PixRGB<byte> > scaledImage = rescaleNI(colorImage, colorImage.getWidth()/2, colorImage.getHeight()/2); 00061 RobotSimEvents::RetinaMessagePtr msg = new RobotSimEvents::RetinaMessage; 00062 msg->img = Image2Ice(scaledImage); 00063 00064 if (i == 0) msg->cameraID = "LFwdCamera"; 00065 else if (i == 1) msg->cameraID = "RFwdCamera"; 00066 else if (i == 2) msg->cameraID = "LDownCamera"; 00067 else if (i == 3) msg->cameraID = "RDownCamera"; 00068 else msg->cameraID = "Unknown"; 00069 00070 this->publish("RetinaMessageTopic", msg); 00071 }*/ 00072 } 00073 00074 // ###################################################################### 00075 void StereoRetinaI::updateMessage(const RobotSimEvents::EventMessagePtr& eMsg, 00076 const Ice::Current&) 00077 { 00078 //Get a retina message 00079 /* 00080 if(eMsg->ice_isA("::RobotSimEvents::CameraConfigMessage")) 00081 { 00082 RobotSimEvents::CameraConfigMessagePtr ccMsg = RobotSimEvents::CameraConfigMessagePtr::dynamicCast(eMsg); 00083 00084 LINFO("Message is a camera config message: cameraID=%s, active:%d", ccMsg->cameraID.c_str(), ccMsg->active); 00085 00086 if(ccMsg->cameraID == itsIceIdentity.getVal()) 00087 itsRunning = ccMsg->active; 00088 00089 } 00090 */ 00091 } 00092 00093