- Timestamp:
- Jan 12, 2017, 10:39:23 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ReleaseNotes
r122 r124 1 1 * Actual Version: 2 2 3 - added lib/FlairCore/src/Semaphore.cpp 3 4 - added fixed cameras in simulator, see $FLAIR_ROOT/flair-bin/models/indoor_fligh 4 5 t_arena.xml for an exemple -
trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.cpp
r122 r124 26 26 #include <GroupBox.h> 27 27 #include <DoubleSpinBox.h> 28 #include <PushButton.h> 28 29 #include <FrameworkManager.h> 29 30 #include <MetaDualShock3.h> … … 49 50 uav->GetVerticalCamera()->SetLogFormat(Camera::LogFormat::JPG); 50 51 getFrameworkManager()->AddDeviceToLog(uav->GetVerticalCamera()); 51 greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::GRAY); 52 53 startOpticalflow=new PushButton(GetButtonsLayout()->NewRow(),"start optical flow"); 52 54 53 uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi? 55 greyCameraImage=new CvtColor(uav->GetVerticalCamera(),"gray",CvtColor::Conversion_t::ToGray); 54 56 55 //optical flow stack 56 opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique"); 57 opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique"); 57 uav->GetVerticalCamera()->UseDefaultPlot(greyCameraImage->Output()); // Le defaultPlot de la caméra peut afficher n'importe quoi? 58 58 59 cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1); 60 for(int i=0;i<2;i++) { 61 desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0)); 62 } 63 cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance 64 for(int i=0;i<2;i++) { 65 prev_value->SetValue(i,0,0); 66 } 59 //optical flow stack 60 opticalFlow=new OpticalFlow(greyCameraImage,uav->GetVerticalCamera()->GetLayout()->NewRow(),"flux optique"); 61 opticalFlowSpeed=new OpticalFlowSpeed(opticalFlow,"vitesse du flux optique"); 67 62 68 opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value); 63 cvmatrix_descriptor* desc=new cvmatrix_descriptor(2,1); 64 for(int i=0;i<2;i++) { 65 desc->SetElementName(i,0,opticalFlowSpeed->Output()->Name(i,0)); 66 } 67 cvmatrix* prev_value=new cvmatrix((const Thread*)this,desc,floatType,uav->ObjectName()); // diamond inheritance 68 for(int i=0;i<2;i++) { 69 prev_value->SetValue(i,0,0); 70 } 71 72 opticalFlowSpeedFiltered=new LowPassFilter(opticalFlowSpeed,uav->GetVerticalCamera()->GetLayout()->NewRow(),"passe bas",prev_value); 69 73 // delete prev_value? 70 74 71 75 getFrameworkManager()->AddDeviceToLog(opticalFlowSpeed); 72 76 73 74 75 77 Tab* opticalFlowTab=new Tab(getFrameworkManager()->GetTabWidget(),"flux optique"); 78 DataPlot1D* xVelocityPlot=new DataPlot1D(opticalFlowTab->NewRow(),"x_velocity",-5,5); 79 DataPlot1D* yVelocityPlot=new DataPlot1D(opticalFlowTab->LastRowLastCol(),"y_velocity",-5,5); 76 80 77 78 79 80 81 xVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(0,0)); 82 xVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(0,0),DataPlot::Blue); 83 yVelocityPlot->AddCurve(opticalFlowSpeed->Output()->Element(1,0)); 84 yVelocityPlot->AddCurve(opticalFlowSpeedFiltered->Matrix()->Element(1,0),DataPlot::Blue); 81 85 82 83 84 85 86 u_x=new Pid(setupLawTab->At(1,0),"u_x"); 87 u_x->UseDefaultPlot(graphLawTab->NewRow()); 88 u_y=new Pid(setupLawTab->At(1,1),"u_y"); 89 u_y->UseDefaultPlot(graphLawTab->LastRowLastCol()); 86 90 87 88 89 91 opticalFlowGroupBox=new GroupBox(GetJoystick()->GetTab()->NewRow(),"consignes fo"); 92 maxXSpeed=new DoubleSpinBox(opticalFlowGroupBox->NewRow(),"debattement x"," m/s",-5,5,0.1,1); 93 maxYSpeed=new DoubleSpinBox(opticalFlowGroupBox->LastRowLastCol(),"debattement y"," m/s",-5,5,0.1,1); 90 94 91 92 93 95 opticalFlowReference=new cvmatrix((const Thread*)this,2,1,floatType); 96 xVelocityPlot->AddCurve(opticalFlowReference->Element(0,0),DataPlot::Green,"consigne"); 97 yVelocityPlot->AddCurve(opticalFlowReference->Element(1,0),DataPlot::Green,"consigne"); 94 98 95 96 97 99 customReferenceOrientation= new AhrsData(this,"reference"); 100 uav->GetAhrs()->AddPlot(customReferenceOrientation,DataPlot::Yellow); 101 AddDataToControlLawLog(customReferenceOrientation); 98 102 } 99 103 … … 107 111 } 108 112 113 void DemoOpticalFlow::StartOpticalFlow(void) { 114 if (SetOrientationMode(OrientationMode_t::Custom)) { 115 Thread::Info("(Re)entering optical flow mode\n"); 116 u_x->Reset(); 117 u_y->Reset(); 118 } else { 119 Thread::Warn("Could not enter optical flow mode\n"); 120 } 121 } 122 123 void DemoOpticalFlow::ExtraCheckPushButton(void) { 124 if(startOpticalflow->Clicked()) { 125 //StartOpticalFlow(); 126 GetUav()->GetVerticalCamera()->SavePictureToFile("./toto.jpg"); 127 128 } 129 } 130 109 131 void DemoOpticalFlow::ExtraCheckJoystick(void) { 110 132 static bool wasOpticalFlowModeButtonPressed=false; … … 113 135 if (!wasOpticalFlowModeButtonPressed) { 114 136 wasOpticalFlowModeButtonPressed=true; 115 if (SetOrientationMode(OrientationMode_t::Custom)) { 116 Thread::Info("(Re)entering optical flow mode\n"); 117 u_x->Reset(); 118 u_y->Reset(); 119 } else { 120 Thread::Warn("Could not enter optical flow mode\n"); 121 } 137 StartOpticalFlow(); 122 138 } 123 139 } else { -
trunk/demos/OpticalFlow/uav/src/DemoOpticalFlow.h
r122 r124 25 25 class GroupBox; 26 26 class DoubleSpinBox; 27 class PushButton; 27 28 } 28 29 namespace filter { … … 46 47 void SignalEvent(Event_t event); 47 48 void ExtraCheckJoystick(void); 49 void ExtraCheckPushButton(void); 48 50 const flair::core::AhrsData *GetReferenceOrientation(void); 49 51 … … 59 61 flair::filter::OpticalFlow *opticalFlow; 60 62 flair::filter::OpticalFlowSpeed *opticalFlowSpeed; 63 flair::gui::PushButton *startOpticalflow,*stopOpticalflow; 64 void StartOpticalFlow(void); 61 65 }; 62 66 -
trunk/lib/FlairCore/src/cvimage.cpp
r15 r124 36 36 img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3); 37 37 break; 38 case Type::Format::G RAY:38 case Type::Format::Gray: 39 39 img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 1); 40 40 break; … … 55 55 img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3); 56 56 break; 57 case Type::Format::G RAY:57 case Type::Format::Gray: 58 58 img = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 1); 59 59 break; -
trunk/lib/FlairCore/src/cvimage.h
r15 r124 39 39 UYVY, /*!< UYVY 16 bits */ 40 40 BGR, /*!< BGR 24 bits */ 41 G RAY, /*!< gray 8 bits */41 Gray, /*!< gray 8 bits */ 42 42 }; 43 43 Type(uint16_t _width, uint16_t _height, Format _format) … … 47 47 size_t pixelSize; 48 48 switch (format) { 49 case Format::G RAY:49 case Format::Gray: 50 50 pixelSize = 1; 51 51 break; -
trunk/lib/FlairSensorActuator/src/Camera.cpp
r123 r124 116 116 void Camera::ProcessUpdate(core::io_data* data) { 117 117 if(getFrameworkManager()->IsLogging() && getFrameworkManager()->IsDeviceLogged(this)) { 118 switch(logFormat) { 119 case LogFormat::JPG: 120 IplImage *img=((cvimage*)data)->img; 121 string filename=getFrameworkManager()->GetLogPath()+"/"+ObjectName()+"_"+std::to_string(data->DataTime())+".jpg"; 122 saveToJpeg(img,filename); 123 break; 118 if(logFormat==LogFormat::JPG) { 119 data->GetMutex(); 120 IplImage *img=((cvimage*)data)->img; 121 string filename=getFrameworkManager()->GetLogPath()+"/"+ObjectName()+"_"+std::to_string(data->DataTime())+".jpg"; 122 switch(((cvimage*)data)->GetDataType().GetFormat()) { 123 case cvimage::Type::Format::Gray: 124 saveToJpeg(img,filename,PictureFormat_t::Gray,PictureFormat_t::Gray); 125 break; 126 case cvimage::Type::Format::BGR: 127 saveToJpeg(img,filename,PictureFormat_t::RGB,PictureFormat_t::RGB); 128 break; 129 case cvimage::Type::Format::UYVY: 130 saveToJpeg(img,filename,PictureFormat_t::UYVY,PictureFormat_t::UYVY); 131 break; 132 default: 133 Warn("cannot log to this format\n"); 134 break; 135 } 136 data->ReleaseMutex(); 124 137 } 125 138 } … … 127 140 } 128 141 129 void Camera::SaveToFile(string filename) const { 142 void Camera::SavePictureToFile(std::string filename) const { 143 string::size_type idx = filename.rfind('.'); 144 145 if(idx != std::string::npos) { 146 Printf("saving %s\n", filename.c_str()); 147 std::string extension = filename.substr(idx+1); 148 149 output->GetMutex(); 150 if(extension=="jpg") { 151 if(output->GetDataType().GetFormat()==cvimage::Type::Format::Gray) saveToJpeg(output->img,filename,PictureFormat_t::Gray,PictureFormat_t::Gray); 152 if(output->GetDataType().GetFormat()==cvimage::Type::Format::BGR) saveToJpeg(output->img,filename,PictureFormat_t::RGB,PictureFormat_t::RGB); 153 if(output->GetDataType().GetFormat()==cvimage::Type::Format::UYVY) saveToJpeg(output->img,filename,PictureFormat_t::UYVY,PictureFormat_t::UYVY); 154 } else { 155 cvSaveImage(filename.c_str(),output->img); 156 } 157 output->ReleaseMutex(); 158 159 } else { 160 Warn("saving %s no file extension!\n", filename.c_str()); 161 } 162 } 163 164 void Camera::SaveRawPictureToFile(string filename) const { 130 165 Printf("saving %s, size %i\n", filename.c_str(), output->img->imageSize); 131 166 std::ofstream pFile; -
trunk/lib/FlairSensorActuator/src/Camera.h
r122 r124 92 92 93 93 /*! 94 * \brief Save raw picture to file 95 * 96 * \param filename filename 97 */ 98 void SaveRawPictureToFile(std::string filename) const; 99 100 /*! 94 101 * \brief Save picture to file 95 102 * 96 103 * \param filename filename 97 104 */ 98 void Save ToFile(std::string filename) const;105 void SavePictureToFile(std::string filename) const; 99 106 100 107 /*! -
trunk/lib/FlairSensorActuator/src/V4LCamera.cpp
r15 r124 43 43 Thread::Err("cvCaptureFromCAM error\n"); 44 44 45 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width) <0)45 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, width)<0) 46 46 Thread::Err("cvSetCaptureProperty error\n"); 47 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height) <0)47 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, height)<0) 48 48 Thread::Err("cvSetCaptureProperty error\n"); 49 49 50 50 if (format == cvimage::Type::Format::UYVY) { 51 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY) < 52 0) 51 if (cvSetCaptureProperty(capture, CV_CAP_PROP_FORMAT, V4L2_PIX_FMT_UYVY)<0) 53 52 Thread::Err("cvSetCaptureProperty error\n"); 54 53 } else if (format == cvimage::Type::Format::YUYV) { -
trunk/lib/FlairVisionFilter/src/CvtColor.cpp
r122 r124 25 25 26 26 switch(conversion) { 27 case Conversion_t:: GRAY:27 case Conversion_t::ToGray: 28 28 try{ 29 29 cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType()); 30 output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),cvimage::Type::Format::G RAY,"conversion",true,2);30 output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),cvimage::Type::Format::Gray,"conversion",true,2); 31 31 32 32 } catch(std::bad_cast& bc) { … … 61 61 62 62 switch(conversion) { 63 case Conversion_t:: GRAY:63 case Conversion_t::ToGray: 64 64 switch(((cvimage*)data)->GetDataType().GetFormat()) { 65 65 case cvimage::Type::Format::YUYV: -
trunk/lib/FlairVisionFilter/src/CvtColor.h
r122 r124 39 39 */ 40 40 enum class Conversion_t { 41 BGR,/*!< BGR 24 bits */42 GRAY,/*!< gray 8 bits */41 ToBGR,/*!< BGR 24 bits */ 42 ToGray,/*!< gray 8 bits */ 43 43 } ; 44 44 -
trunk/lib/FlairVisionFilter/src/HoughLines.cpp
r122 r124 53 53 try{ 54 54 cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType()); 55 if(imageType.GetFormat()!=cvimage::Type::Format::G RAY) {56 Err("input image is not gr ey\n");55 if(imageType.GetFormat()!=cvimage::Type::Format::Gray) { 56 Err("input image is not gray\n"); 57 57 } 58 58 } catch(std::bad_cast& bc) { -
trunk/lib/FlairVisionFilter/src/ImgThreshold.cpp
r122 r124 32 32 try{ 33 33 cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType()); 34 if(imageType.GetFormat()==cvimage::Type::Format::G RAY) {34 if(imageType.GetFormat()==cvimage::Type::Format::Gray) { 35 35 output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"threshold"); 36 36 } else { 37 Err("input image is not gr ey\n");37 Err("input image is not gray\n"); 38 38 } 39 39 } catch(std::bad_cast& bc) { -
trunk/lib/FlairVisionFilter/src/Sobel.cpp
r122 r124 34 34 try{ 35 35 cvimage::Type const &imageType=dynamic_cast<cvimage::Type const &>(parent->GetOutputDataType()); 36 if(imageType.GetFormat()==cvimage::Type::Format::G RAY) {36 if(imageType.GetFormat()==cvimage::Type::Format::Gray) { 37 37 output=new cvimage(this,imageType.GetWidth(),imageType.GetHeight(),imageType.GetFormat(),"sobel"); 38 38 } else { 39 Err("input image is not gr ey\n");39 Err("input image is not gray\n"); 40 40 } 41 41 -
trunk/lib/FlairVisionFilter/src/VisionFilter.cpp
r123 r124 9 9 } 10 10 11 void saveToJpeg(IplImage* src_img,std::string filename, unsigned char compression_level) {11 void saveToJpeg(IplImage* src_img,std::string filename,PictureFormat_t input_format,PictureFormat_t output_format,unsigned char compression_level) { 12 12 if(!cvSaveImage(filename.c_str(),src_img)) printf("Could not save.\n"); 13 13 } -
trunk/lib/FlairVisionFilter/src/VisionFilter.h
r123 r124 12 12 void CloseVisionFilter(void); 13 13 14 void saveToJpeg(IplImage* src_img,std::string filename,unsigned char compression_level=95); 14 enum class PictureFormat_t { 15 Gray,/*!< gray 8 bits */ 16 RGB,/*!< rgb 24 bits */ 17 UYVY,/*!< YUV 4:2:2 planer */ 18 } ; 19 20 void saveToJpeg(IplImage* src_img,std::string filename,PictureFormat_t input_format,PictureFormat_t output_format,unsigned char compression_level=95); -
trunk/lib/FlairVisionFilter/src/unexported/compile_info.h
r123 r124 5 5 6 6 #define USER "gsanahuj@gsanahuj-Latitude-E6420" 7 #define DATE " mardi 10 janvier 2017, 15:56:33(UTC+0100)"7 #define DATE "jeudi 12 janvier 2017, 09:32:25 (UTC+0100)" 8 8 #define GCC_REV "4.9.1" 9 9 #define GCC_PATH "/opt/robomap3/1.7.3/armv7a-neon/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-gcc" 10 10 #define SVN_PATH "/home/gsanahuj/HDS/igep/flair-src_svn/trunk/lib/FlairVisionFilter" 11 #define SVN_REV "122 M"11 #define SVN_REV "122:123M" 12 12 13 13 inline void compile_info(std::string name) {
Note:
See TracChangeset
for help on using the changeset viewer.