nxt_ar_toolkit
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
nxt_ar_toolkit [2016/08/02 22:09] – dwallace | nxt_ar_toolkit [2017/07/17 03:13] (current) – [Step 8: Using Multiple Markers for Localization and Navigation] dwallace | ||
---|---|---|---|
Line 3: | Line 3: | ||
**Author:** Dylan Wallace Email: < | **Author:** Dylan Wallace Email: < | ||
\\ | \\ | ||
- | **Date:** Last modified on 08/02/16 | + | **Date:** Last modified on 08/28/16 |
\\ | \\ | ||
**Keywords: | **Keywords: | ||
Line 19: | Line 19: | ||
* Know how to use basic Linux and Windows commands | * Know how to use basic Linux and Windows commands | ||
\\ | \\ | ||
- | * Perhaps also know how to program in C/C++, especially with Visual Studio. | + | * Perhaps also know how to program in C/Cpp, especially with Visual Studio. |
\\ | \\ | ||
* Perhaps additional background needed may include experience with other frameworks such as OpenCV or OpenGL. | * Perhaps additional background needed may include experience with other frameworks such as OpenCV or OpenGL. | ||
Line 44: | Line 44: | ||
==== Step 3: Obtain Missing DLLs ==== | ==== Step 3: Obtain Missing DLLs ==== | ||
- | If you are running on a newer Windows installation, | + | If you are running on a newer Windows installation, |
===== Using the ARToolkit ===== | ===== Using the ARToolkit ===== | ||
Line 98: | Line 98: | ||
Once you have the example program simpleLite working well with marker recognition and tracking, you can move onto creating your own project. For developing your own projects using the ARToolkit, I recommend using Visual Studio 2013 or higher. Visual Studio has great support for the ARToolkit SDK, and all of their example projects have been provided as Visual Studio projects to modify or use as reference. | Once you have the example program simpleLite working well with marker recognition and tracking, you can move onto creating your own project. For developing your own projects using the ARToolkit, I recommend using Visual Studio 2013 or higher. Visual Studio has great support for the ARToolkit SDK, and all of their example projects have been provided as Visual Studio projects to modify or use as reference. | ||
- | To begin with creating | + | **Note:** With recent updates to ARToolkit, it can be very difficult to create |
- | Once you have created the project, you will need to add the include and library directories to your project. Do this by right-clicking the project, and going to Properties. Under properties, look for the VC++ Directories tab. First click on the drop-down for include directories, | + | To begin with creating a new project, simply open up Visual Studio and create an empty Visual Cpp project. Once you have created the empty project, you will need to add a .c file to the project. I named my file coordinate_tracking.c, |
+ | |||
+ | Once you have created the project, you will need to add the include and library directories to your project. Do this by right-clicking the project, and going to Properties. Under properties, look for the VCpp Directories tab. First click on the drop-down for include directories, | ||
Finally, you need to copy over some data from the ARToolkit5 bin folder. First, copy the Data folder over to your project folder. Next, copy DSVL.dll, DSVLd.dll, ARvideo.dll, | Finally, you need to copy over some data from the ARToolkit5 bin folder. First, copy the Data folder over to your project folder. Next, copy DSVL.dll, DSVLd.dll, ARvideo.dll, | ||
Line 193: | Line 195: | ||
{{ youtube> | {{ youtube> | ||
+ | ==== Step 7: Tracking Multiple Markers ==== | ||
+ | |||
+ | In order to use the ARToolkit SDK for tracking of objects or for any kind of computer vision application, | ||
+ | |||
+ | **Changing from pattern-detection to barcode-detection** | ||
+ | |||
+ | First you will need to remove the references to the pattern style, because we are no longer using pattern-detection. To do this, comment out the lines in the beginning of the program around line 25 (depending on your code) where it defines the pattern name, and where it initializes the pattern handle. | ||
+ | |||
+ | //# | ||
+ | | ||
+ | // | ||
+ | | ||
+ | Now you will need to add the barcode-detection to the main function. Places these two lines of code right before the function call for argMainLoop(): | ||
+ | |||
+ | arSetPatternDetectionMode(arHandle, | ||
+ | arSetMatrixCodeType(arHandle, | ||
+ | | ||
+ | This will setup the marker-detection into barcode-matrix mode, allowing the ARToolkit to detect these markers instead of the traditional style of marker. | ||
+ | |||
+ | **Tracking Coordinates of Multiple Markers** | ||
+ | |||
+ | In order to consistently track the coordinates of multiple markers, you will need to alter the detection algorithm to associate one barcode ID with one instance of an array for storing your coordinates. To do this, add these lines of code to the main detection loop, after the IDs and CF values are logged to the ARConsole (Please change xCoord and yCoord to arrays that have the size as the amount of markers to track (currently 8 in this example)): | ||
+ | |||
+ | for (h = 0; h < 7; h++) { | ||
+ | | ||
+ | if (markerInfo[j].idMatrix == h) { | ||
+ | yCoord[h] = (yReal / ysize)*(ysize - markerInfo[j].pos[1]); | ||
+ | xCoord[h] = (xReal / xsize)*(markerInfo[j].pos[0]); | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | Now we will be adding to this for loop in order to use our tracked coordinates for localization and navigation within an area. | ||
+ | |||
+ | ==== Step 8: Using Multiple Markers for Localization and Navigation ==== | ||
+ | |||
+ | In order to track the position of a robot or other vehicle using the ARToolkit, we will need to create an algorithm that creates relative coordinates for the robot based off of a known location of a stationary marker. This will allows us to create a kind of coordinate system that is independent of camera position or resolution. In order to do this, we will need to use one barcode marker (in most cases this will be number 0) fixed to a stationary location, and then reference this location in our code to get relative distances. | ||
+ | |||
+ | if ((xCoord[0] != 0) && (yCoord[0] != 0) && (xCoord[h] < 1000) && (yCoord[h] < 1000) && (xCoord[h] > -1000) && (yCoord[h] > -1000)) { | ||
+ | xCoordRel[h] = xCoord[h] - xCoord[0]; | ||
+ | yCoordRel[h] = yCoord[h] - yCoord[0]; | ||
+ | ARLOG(" | ||
+ | sprintf(xValue[h], | ||
+ | sprintf(yValue[h], | ||
+ | argDrawStringsByIdealPos(xValue[h], | ||
+ | argDrawStringsByIdealPos(yValue[h], | ||
+ | } | ||
+ | |||
+ | This if statement will store the positions of these markers into a separate array for relative positions, ensuring that normal tracking is unaffected by this. This will also output those relative distances to the screen using the last 5 lines of code. Since this is located within that same for loop from above, this will keep everything sorted into the proper positions of their array. The conditional statement for this step is checking to make sure that the reference marker is stored, and that the marker it is trying to calculate for is being recognized correctly (hence the over 1000 value). Once you have added this to your code, you should | ||
+ | \\ | ||
+ | {{ youtube> | ||
+ | \\ | ||
===== Final Words ===== | ===== Final Words ===== | ||
- | This tutorial' | + | This tutorial' |
\\ | \\ | ||
\\ | \\ | ||
Line 201: | Line 254: | ||
\\ | \\ | ||
\\ | \\ | ||
- | For questions, clarifications, | + | For questions, clarifications, |
nxt_ar_toolkit.1470200962.txt.gz · Last modified: 2016/08/02 22:09 by dwallace