- Timestamp:
- Mar 1, 2017, 3:38:42 PM (8 years ago)
- Location:
- trunk/lib
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairSensorActuator/src/SimuCamera.cpp
r150 r151 19 19 #include <FrameworkManager.h> 20 20 #include <GroupBox.h> 21 #include <SpinBox.h>22 //#include <cvimage.h>23 21 #include <SharedMem.h> 24 22 #include <sstream> … … 32 30 namespace sensor { 33 31 32 //control part 34 33 SimuCamera::SimuCamera(string name, 35 34 uint16_t width, uint16_t height, uint8_t channels, … … 37 36 : Thread(getFrameworkManager(), name, priority), 38 37 Camera(name, width, height, cvimage::Type::Format::BGR) { 39 // data_rate =40 // new SpinBox(GetGroupBox()->NewRow(), "data rate", " Hz", 1, 200, 1, 50);41 38 42 buf_size = width * height * channels ;39 buf_size = width * height * channels+sizeof(Time); 43 40 44 img = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);45 output->img->imageData = img->imageData;41 shmemReadBuf=(char*)malloc(buf_size); 42 output->img->imageData = shmemReadBuf; 46 43 47 44 ostringstream dev_name; … … 50 47 } 51 48 49 //simulation part 52 50 SimuCamera::SimuCamera(const IODevice *parent, string name, uint16_t width, 53 51 uint16_t height, uint8_t channels, uint32_t dev_id) 54 52 : Thread(parent, name, 0), Camera(parent,name) { 55 // data_rate = NULL;56 53 54 buf_size = width * height * channels+sizeof(Time); 55 57 56 ostringstream dev_name; 58 57 dev_name << "simu_cam_" << dev_id; 59 58 shmem = new SharedMem((Thread *)this, dev_name.str().c_str(), 60 width * height * channels, SharedMem::Type::producerConsumer); 59 buf_size, SharedMem::Type::producerConsumer); 60 shmemReadBuf=NULL; 61 61 } 62 62 … … 64 64 SafeStop(); 65 65 Join(); 66 if(shmemReadBuf!=NULL) delete shmemReadBuf; 66 67 } 67 68 68 69 void SimuCamera::Run(void) { 70 Time time; 69 71 // if (data_rate == NULL) { 70 72 // Thread::Err("not applicable for simulation part.\n"); … … 84 86 output->GetMutex(); 85 87 //blocking read 86 shmem->Read( (char *)img->imageData, buf_size); // remplacer copie par88 shmem->Read(shmemReadBuf, buf_size); // remplacer copie par 87 89 // échange de pointeur sur 88 90 // double buffering 89 91 output->ReleaseMutex(); 90 91 output->SetDataTime( GetTime());92 memcpy(&time,shmemReadBuf+buf_size-sizeof(Time),sizeof(Time)); 93 output->SetDataTime(time); 92 94 93 95 ProcessUpdate(output); -
trunk/lib/FlairSensorActuator/src/SimuCamera.h
r144 r151 21 21 namespace core { 22 22 class SharedMem; 23 }24 namespace gui {25 class SpinBox;26 23 } 27 24 } … … 99 96 void UpdateFrom(const core::io_data *data){}; 100 97 101 gui::SpinBox *data_rate;102 98 size_t buf_size; 103 IplImage *img;99 char* shmemReadBuf; 104 100 }; 105 101 } // end namespace sensor -
trunk/lib/FlairSimulator/src/Model_impl.cpp
r148 r151 204 204 205 205 nodeOrientation.ToEuler(euler); 206 ISceneNode::setRotation(Euler::ToDegree(1) * 207 vector3df(euler.roll, euler.pitch, euler.yaw)); 206 ISceneNode::setRotation(Euler::ToDegree(1) * vector3df(euler.roll,euler.pitch, euler.yaw)); 208 207 209 208 if (position_init == false) { -
trunk/lib/FlairSimulator/src/SimuCameraGL.cpp
r147 r151 59 59 index = 0; 60 60 61 buffer = (char *)malloc(width * height * 3);62 63 61 // user interface 64 62 Tab *setup_tab = new Tab(parent->GetTabWidget(), name); … … 86 84 glGenBuffersARB(PBO_COUNT, pboIds); 87 85 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[0]); 88 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width * height * 3 , 0,86 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width * height * 3+sizeof(Time), 0, 89 87 GL_STREAM_READ_ARB); 90 88 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[1]); 91 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width * height * 3 , 0,89 glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, width * height * 3+sizeof(Time), 0, 92 90 GL_STREAM_READ_ARB); 93 91 … … 95 93 } else { 96 94 use_pbo = false; 95 buffer = (char *)malloc(width * height * 3+sizeof(Time)); 97 96 Thread::Warn("GL_ARB_pixel_buffer_object is not suppoorted\n"); 98 97 } … … 106 105 107 106 SimuCameraGL::~SimuCameraGL() { 108 free(buffer);109 110 107 if (use_pbo) { 111 108 glDeleteBuffersARB(PBO_COUNT, pboIds); 112 109 free(pboIds); 110 } else { 111 free(buffer); 113 112 } 114 113 } … … 151 150 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[index]); 152 151 glReadPixels(x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, 0); 153 152 Time time=GetTime(); 154 153 // map the PBO that contain framebuffer pixels before processing it 155 154 glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[nextIndex]); … … 157 156 GL_PIXEL_PACK_BUFFER_ARB, GL_READ_WRITE_ARB); // GL_READ_ONLY_ARB); 158 157 if (src) { 159 putImage((char *)src );158 putImage((char *)src,time); 160 159 glUnmapBufferARB( 161 160 GL_PIXEL_PACK_BUFFER_ARB); // release pointer to the mapped buffer … … 164 163 } else { 165 164 glReadPixels(x, y, width, height, GL_BGR, GL_UNSIGNED_BYTE, buffer); 166 putImage(buffer );165 putImage(buffer,GetTime()); 167 166 } 168 167 … … 173 172 } 174 173 175 void SimuCameraGL::putImage(char *buf ) {174 void SimuCameraGL::putImage(char *buf,Time imageTime) { 176 175 if (invert_pixel == true) { 177 176 // opengl images are horizontally flipped, so we have to fix that here. … … 189 188 delete[] tmpBuffer; 190 189 } 191 192 shmem->Write(buf, width * height * 3 );190 memcpy(buf+width * height * 3,&imageTime,sizeof(Time)); 191 shmem->Write(buf, width * height * 3+sizeof(Time)); 193 192 } 194 193 -
trunk/lib/FlairSimulator/src/SimuCameraGL.h
r15 r151 67 67 irr::scene::ISceneManager *newManager = 0); 68 68 void getImage(void); 69 void putImage(char *pixels );69 void putImage(char *pixels,core::Time imageTime); 70 70 irr::scene::ICameraSceneNode *camera; 71 71 irr::scene::ISceneManager *smgr;
Note:
See TracChangeset
for help on using the changeset viewer.