i've been trying texturemap irrlicht 3d model opencv camera augmented reality project, im using irrlicht 1.8.1 , opencv 2.4.9, , got texturemapping done, problem there weird lines coming in camera feed , below 4fps , output appears in screenshot (below) :
i have following code this:
#include <irrlicht.h> #include "driverchoice.h" #include <opencv/cv.h> #include <opencv/cxcore.h> #include <opencv/highgui.h> #include <time.h> #include <sys/timeb.h> #include <opencv2\highgui\highgui.hpp> #include <iguienvironment.h> using namespace cv; using namespace irr; using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui; #ifdef _msc_ver #pragma comment(lib, "irrlicht.lib") #endif #ifdef _irr_windows_ #pragma comment(lib, "irrlicht.lib") #pragma comment(linker, "/subsystem:windows /entry:maincrtstartup") #endif int main() { irrlichtdevice *device = createdevice(video::edt_opengl, dimension2d<s32> (640 , 480), 16, false, true /* shadow */, false); if (!device) return 1; device->setwindowcaption(l"hello world! - irrlicht engine demo"); ivideodriver* driver = device->getvideodriver(); iscenemanager* smgr = device->getscenemanager(); iguienvironment* guienv = device->getguienvironment(); itexture* frame_tex = driver->addtexture(vector2d<s32>(640, 480), "video_stream"); guienv->addstatictext(l"hello world! irrlicht software renderer!", rect<s32>(10,10,260,22), true); ianimatedmesh* mesh = smgr->getmesh("e:/akshay/vs2012projects/irrlichtdemoapp/irrlichtdemoapp/ratamahatta.md2"); if (!mesh) { device->drop(); return 1; } ianimatedmeshscenenode* node = smgr->addanimatedmeshscenenode( mesh ); if (node) { node->setmaterialflag(emf_lighting, false); node->setmd2animation(scene::emat_stand); node->setmaterialtexture( 0, driver->gettexture("e:/akshay/vs2012projects/irrlichtdemoapp/irrlichtdemoapp/ctf_r.png") ); } smgr->addcamerascenenode(0, vector3df(20,30,-50), vector3df(0,5,0)); while(device->run()) { videocapture capture(0); mat camera_frame; if( cv::waitkey(50) >= 0 ) break; if( !capture.grab() ) { std::cout << "unable grab camera frame\n"; } capture >> camera_frame; if( ! camera_frame.empty() ) { //exception here unsigned char *tex_buf = (unsigned char*)frame_tex->lock(); unsigned char *frame_buf = camera_frame.data; // convert rgb rgba for(int y=0; y < camera_frame.rows; y++) { for(int x=0; x < camera_frame.cols; x++) { *(tex_buf++) = *(frame_buf++); *(tex_buf++) = *(frame_buf++); *(tex_buf++) = *(frame_buf++); *(tex_buf++) = 255; } } frame_tex->unlock(); driver->beginscene(true, true, scolor(255,100,101,140)); driver->draw2dimage(frame_tex, core::rect<s32>(0,0,640,480), core::rect<s32>(0,0,480,640)); smgr->drawall(); guienv->drawall(); driver->endscene(); } } device->drop(); }
any appreciated!
thanks in advance!
i solved issue, problem laptop, tried doing in pc , working fine. because of s32 , changed u32 , works fine now. help!
Comments
Post a Comment