artoolkitx / artoolkit5

ARToolKit v5.x
Other
108 stars 28 forks source link

nftSimple tracking not working on linux #173

Open subjectdenied opened 4 years ago

subjectdenied commented 4 years ago

i just tried this example on linux using my laptop webcam on a xps13 9380, and it doesnt do any tracking. however when trying the asm examples using jsartoolkit5, the cam has no problem tracking the famous pinball image. tried released binaries as well as compiling myself

kalwalt commented 4 years ago

Hi @subjectdenied do you receive some message from the console? Note that for jsartoolkit5 we can't use the same code because is multithreaded. We use a modified version. Maybe wasn't enabled the -pthread flag during compilation? i don't know... just making supposition.

subjectdenied commented 4 years ago

hi, no there is no error, it just doesnt seem to detect the image at all, while telling me that 8 threads for tracking where started. i get however an error when the v4l2 cam is initialzed, telling about an ioctl error, so i guess it has something to do with with the webcam-support in linux using v4l2

btw this project is amazing (but sadly doesnt get the love from opensource-community that it would deserve), and i really want to congratulate you guys for getting NFT working on the web - this is an amazing achievement

kalwalt commented 4 years ago

Thank you @subjectdenied ! It was a collective effort! Btw i had a similar issue trying the tracking2d (with artoolkitX) feature under Linux, no errors in the console only an error regarding the camera as you said. I have fear that Artoolkit5 under Linux is not well tested...

kalwalt commented 4 years ago

@subjectdenied should test also the other examples if the issue persist also for the simple example , maybe is something is broken for Linux OS.

subjectdenied commented 4 years ago

i looked into the v4l2 code a bit, and i think that values regarding cam capabilities (brightness, saturation, ...) are wrongly parsed which then leads to this ioctl error. i might try to fix this, if i can find the time

yes it is a problem with every example, also debugging mode in simpleTest doesn't refresh, but only shows the first frame always

kalwalt commented 4 years ago

i looked into the v4l2 code a bit, and i think that values regarding cam capabilities (brightness, saturation, ...) are wrongly parsed which then leads to this ioctl error. i might try to fix this, if i can find the time

yes it is a problem with every example, also debugging mode in simpleTest doesn't refresh, but only shows the first frame always

Good to know, ping me if you have an update on this.

subjectdenied commented 4 years ago

@kalwalt actually i fixed it, first it doesnt work at all with v4l2, you have to use the gstreamer pipe like this (this is for my notebook-webcam)

nftSimple -device=GStreamer "v4l2src device="/dev/video0" ! videoconvert ! video/x-raw,format=RGB,width=640,height=480,framerate=30/1 ! identity name=artoolkit sync=true ! fakesink"

but there is also another issue with cli-args (precisely the gstreamer arg) not parsed correctly, the beginning of main in nftSimple has to look like this (it is exactly how simpleTest is parsing the args):

' ... int main(int argc, char* argv) { char glutGamemode[32]; char cparam_name = NULL; char vconf[512]; const char markerConfigDataFilename[] = "Data2/markers.dat"; int i;

if( argc == 1 ) vconf[0] = '\0';
else {
    strcpy( vconf, argv[1] );
    for( i = 2; i < argc; i++ ) {strcat(vconf, " "); strcat(vconf,argv[i]);}
}

ifdef DEBUG

arLogLevel = AR_LOG_LEVEL_DEBUG;

endif

//
// Library inits.
//

glutInit(&argc, argv);

... '

after that the pinball image works showing a small cube

kalwalt commented 4 years ago

Glad to know! It will be nice to fix this in the repo, and maybe testing with the other OS (Mac and Windows) @ThorstenBux can you take a look at? I would also test your changes @subjectdenied

kalwalt commented 4 years ago

@subjectdenied i tested the binaries from https://github.com/artoolkitx/artoolkit5/releases/tag/5.4.0 an i have the same result, no errors and no tracking. I will test and try to rebuild the project with your proposed changes.