Permalink
Browse files

- multimodel loading

	modified:   ../artvertiser.layout
	modified:   artvertiser.cpp
	new file:   artverts/spider.png
	new file:   artverts/your_art_here.png
	new file:   camparams_qc9000_damian/camera_c.txt
	new file:   camparams_qc9000_damian/camera_r_t.txt
	new file:   camparams_qc9000_damian/view_r_t.txt
	modified:   models.xml
	new file:   models/nothing
	new file:   models/ships.bmp
	new file:   models/ships.bmp.artvertroi
	new file:   models/ships.bmp.classifier/corners.txt
	new file:   models/ships.bmp.classifier/keypoints.txt
	new file:   models/ships.bmp.classifier/misclassification_rates.txt
	new file:   models/ships.bmp.classifier/original_image.bmp
	new file:   models/ships.bmp.classifier/parameters.txt
	new file:   models/ships.bmp.classifier/thresholds.txt
	new file:   models/ships.bmp.classifier/tree0000.txt
	new file:   models/ships.bmp.classifier/tree0001.txt
	new file:   models/ships.bmp.classifier/tree0002.txt
	new file:   models/ships.bmp.classifier/tree0003.txt
	new file:   models/ships.bmp.classifier/tree0004.txt
	new file:   models/ships.bmp.classifier/tree0005.txt
	new file:   models/ships.bmp.classifier/tree0006.txt
	new file:   models/ships.bmp.classifier/tree0007.txt
	new file:   models/ships.bmp.classifier/tree0008.txt
	new file:   models/ships.bmp.classifier/tree0009.txt
	new file:   models/ships.bmp.classifier/tree0010.txt
	new file:   models/ships.bmp.classifier/tree0011.txt
	new file:   models/ships.bmp.classifier/weights.txt
	new file:   models/ships.bmp.roi
	new file:   models/ships.bmp_initial_points.bmp
	new file:   models/ships.bmp_stable_points.bmp
  • Loading branch information...
1 parent faef33a commit e620f9bbcebb412973d3861b56713d2136982f15 @damian0815 damian0815 committed Feb 3, 2010
Showing with 293,858 additions and 85 deletions.
  1. +13 −13 artvertiser.layout
  2. +71 −51 artvertiser/artvertiser.cpp
  3. BIN artvertiser/artverts/spider.png
  4. BIN artvertiser/artverts/your_art_here.png
  5. +7 −0 artvertiser/camparams_qc9000_damian/camera_c.txt
  6. +7 −0 artvertiser/camparams_qc9000_damian/camera_r_t.txt
  7. +225 −0 artvertiser/camparams_qc9000_damian/view_r_t.txt
  8. +46 −21 artvertiser/models.xml
  9. 0 artvertiser/models/nothing
  10. BIN artvertiser/models/ships.bmp
  11. +4 −0 artvertiser/models/ships.bmp.artvertroi
  12. +4 −0 artvertiser/models/ships.bmp.classifier/corners.txt
  13. +501 −0 artvertiser/models/ships.bmp.classifier/keypoints.txt
  14. +500 −0 artvertiser/models/ships.bmp.classifier/misclassification_rates.txt
  15. BIN artvertiser/models/ships.bmp.classifier/original_image.bmp
  16. +2 −0 artvertiser/models/ships.bmp.classifier/parameters.txt
  17. +500 −0 artvertiser/models/ships.bmp.classifier/thresholds.txt
  18. +24,169 −0 artvertiser/models/ships.bmp.classifier/tree0000.txt
  19. +24,640 −0 artvertiser/models/ships.bmp.classifier/tree0001.txt
  20. +24,385 −0 artvertiser/models/ships.bmp.classifier/tree0002.txt
  21. +23,816 −0 artvertiser/models/ships.bmp.classifier/tree0003.txt
  22. +24,978 −0 artvertiser/models/ships.bmp.classifier/tree0004.txt
  23. +23,706 −0 artvertiser/models/ships.bmp.classifier/tree0005.txt
  24. +24,397 −0 artvertiser/models/ships.bmp.classifier/tree0006.txt
  25. +24,748 −0 artvertiser/models/ships.bmp.classifier/tree0007.txt
  26. +24,477 −0 artvertiser/models/ships.bmp.classifier/tree0008.txt
  27. +23,942 −0 artvertiser/models/ships.bmp.classifier/tree0009.txt
  28. +23,954 −0 artvertiser/models/ships.bmp.classifier/tree0010.txt
  29. +24,250 −0 artvertiser/models/ships.bmp.classifier/tree0011.txt
  30. +512 −0 artvertiser/models/ships.bmp.classifier/weights.txt
  31. +4 −0 artvertiser/models/ships.bmp.roi
  32. BIN artvertiser/models/ships.bmp_initial_points.bmp
  33. BIN artvertiser/models/ships.bmp_stable_points.bmp
View
@@ -22,10 +22,10 @@
<File name="artvertiser/FProfiler/FTime.h" open="0" top="0" tabpos="28">
<Cursor position="1729" topLine="71" />
</File>
- <File name="artvertiser/MatrixTracker/MatrixTracker.cpp" open="1" top="0" tabpos="3">
+ <File name="artvertiser/MatrixTracker/MatrixTracker.cpp" open="1" top="0" tabpos="1">
<Cursor position="10933" topLine="261" />
</File>
- <File name="artvertiser/MatrixTracker/MatrixTracker.h" open="1" top="0" tabpos="5">
+ <File name="artvertiser/MatrixTracker/MatrixTracker.h" open="1" top="0" tabpos="3">
<Cursor position="3393" topLine="43" />
</File>
<File name="artvertiser/MatrixTracker/ofxMatrix3x3.cpp" open="0" top="0" tabpos="34">
@@ -55,11 +55,11 @@
<File name="artvertiser/MatrixTracker/ofxVec4f.h" open="0" top="0" tabpos="0">
<Cursor position="122" topLine="2" />
</File>
- <File name="artvertiser/artvertiser.cpp" open="1" top="0" tabpos="2">
- <Cursor position="2996" topLine="75" />
+ <File name="artvertiser/artvertiser.cpp" open="1" top="1" tabpos="11">
+ <Cursor position="3554" topLine="118" />
</File>
- <File name="artvertiser/calibmodel.cpp" open="1" top="0" tabpos="9">
- <Cursor position="1376" topLine="41" />
+ <File name="artvertiser/calibmodel.cpp" open="1" top="0" tabpos="7">
+ <Cursor position="853" topLine="27" />
</File>
<File name="artvertiser/calibmodel.h" open="0" top="0" tabpos="6">
<Cursor position="372" topLine="0" />
@@ -73,13 +73,13 @@
<File name="artvertiser/multigrab.cpp" open="0" top="0" tabpos="4">
<Cursor position="3892" topLine="20" />
</File>
- <File name="artvertiser/multigrab.h" open="1" top="0" tabpos="6">
+ <File name="artvertiser/multigrab.h" open="1" top="0" tabpos="4">
<Cursor position="925" topLine="8" />
</File>
- <File name="artvertiser/multithreadcapture.cpp" open="1" top="0" tabpos="7">
+ <File name="artvertiser/multithreadcapture.cpp" open="1" top="0" tabpos="5">
<Cursor position="20018" topLine="606" />
</File>
- <File name="artvertiser/multithreadcapture.h" open="1" top="0" tabpos="8">
+ <File name="artvertiser/multithreadcapture.h" open="1" top="0" tabpos="6">
<Cursor position="3870" topLine="72" />
</File>
<File name="garfeild/calib/CamAugmentation.cpp" open="0" top="0" tabpos="22">
@@ -109,7 +109,7 @@
<File name="garfeild/keypoints/keypoint_orientation_corrector.h" open="0" top="0" tabpos="19">
<Cursor position="2825" topLine="49" />
</File>
- <File name="garfeild/keypoints/yape.cpp" open="1" top="0" tabpos="4">
+ <File name="garfeild/keypoints/yape.cpp" open="1" top="0" tabpos="2">
<Cursor position="20440" topLine="700" />
</File>
<File name="garfeild/keypoints/yape.h" open="0" top="0" tabpos="10">
@@ -124,7 +124,7 @@
<File name="garfeild/lightcalib/lightmap.h" open="0" top="0" tabpos="13">
<Cursor position="1669" topLine="16" />
</File>
- <File name="garfeild/viewsets/affine_image_generator.cpp" open="1" top="0" tabpos="12">
+ <File name="garfeild/viewsets/affine_image_generator.cpp" open="1" top="0" tabpos="10">
<Cursor position="18981" topLine="564" />
</File>
<File name="garfeild/viewsets/affine_image_generator.h" open="0" top="0" tabpos="7">
@@ -157,10 +157,10 @@
<File name="garfeild/viewsets/object_view.h" open="0" top="0" tabpos="25">
<Cursor position="1509" topLine="38" />
</File>
- <File name="garfeild/viewsets/planar_object_recognizer.cpp" open="1" top="1" tabpos="10">
+ <File name="garfeild/viewsets/planar_object_recognizer.cpp" open="1" top="0" tabpos="8">
<Cursor position="6187" topLine="185" />
</File>
- <File name="garfeild/viewsets/planar_object_recognizer.h" open="1" top="0" tabpos="11">
+ <File name="garfeild/viewsets/planar_object_recognizer.h" open="1" top="0" tabpos="9">
<Cursor position="9133" topLine="216" />
</File>
<File name="starter/geometry/projection_matrix.cpp" open="0" top="0" tabpos="0">
View
@@ -167,6 +167,7 @@ IplImage *image2 = cvLoadImage("artvert2.png");
IplImage *image3 = cvLoadImage("artvert3.png");
IplImage *image4 = cvLoadImage("artvert4.png");
IplImage *image5 = cvLoadImage("artvert5.png");
+IplImage *fallback_artvert_image = cvLoadImage("artvert1.png");
// matrix tracker
MatrixTracker matrix_tracker;
@@ -220,18 +221,53 @@ CvPoint2D32f *c1 = new CvPoint2D32f[4];
vector<int> artvert_roi_vec;
char *image_path;
-typedef struct _Artvert
+
+class Artvert
{
+public:
+ Artvert() {
+ artvert_image=0;
+ model_file="model.bmp";
+ artvert_image_file="artvert1.png";
+ artist = "unknown artist";
+ advert = "unknown advert";
+ name = "unnamed artvert";
+ }
+ ~Artvert()
+ {
+ if ( artvert_image )
+ cvReleaseImage( &artvert_image );
+ }
+
+ IplImage* getArtvertImage()
+ {
+ printf("get artvert image called\n");
+ if ( !artvert_image )
+ {
+ printf("loading artvert image '%s'\n", artvert_image_file.c_str() );
+ artvert_image = cvLoadImage( artvert_image_file.c_str() );
+ }
+ if ( !artvert_image )
+ {
+ fprintf(stderr, "couldn't load artvert image '%s'\n", artvert_image_file.c_str() );
+ artvert_image = fallback_artvert_image;
+ }
+ return artvert_image;
+ }
+
string model_file;
string artvert_image_file;
string artist;
string advert;
string name;
-} Artvert;
+private:
+ IplImage* artvert_image;
+};
vector< Artvert > artvert_list;
-int which_artvert=0;
-bool next_artvert_requested = false;
+int current_artvert_index=0;
+bool new_artvert_requested = false;
+int new_artvert_requested_index = 0;
vector< bool > model_file_needs_training;
#include "ofxXmlSettings/ofxXmlSettings.h"
@@ -611,25 +647,10 @@ bool loadOrTrain( int new_index )
c1[3].x = roi_vec[6];
c1[3].y = roi_vec[7];
- return true;
-
-}
+ current_artvert_index = new_index;
+ return true;
-bool loadOrTrainNext()
-{
- // get next filename
- string filename = artvert_list.at(which_artvert).model_file;
- printf("next model requested: loading model %i:%s\n", which_artvert, filename.c_str() );
- // load or train
- bool success = loadOrTrain( which_artvert /*model_file_needs_training.at(which_artvert ), filename.c_str()*/ );
- // store if we need to train again
- model_file_needs_training[which_artvert ] = !success;
-
- // for next time
- which_artvert = (which_artvert +1)%artvert_list.size();
-
- return success;
}
@@ -669,10 +690,7 @@ static bool init( int argc, char** argv )
usage(argv[0]);
Artvert a;
a.model_file = argv[i+1];
- a.artist = "unknown artist";
- a.name = "cmdline";
- a.advert = "unknown advert";
- a.artvert_image_file = "artvert1.png";
+ a.advert = "cmdline "+a.model_file;
// store
artvert_list.push_back( a );
printf(" -m: adding model image '%s'\n", argv[i+1] );
@@ -783,21 +801,27 @@ static bool init( int argc, char** argv )
if ( data.getNumTags( "artverts" ) == 1 )
{
data.pushTag( "artverts" );
- int num_filenames = data.getNumTags( "artvert" );
- printf(" -ml: opened %s, %i artverts\n", model_file_list_file, num_filenames );
+ int num_filenames = data.getNumTags( "advert" );
+ printf(" -ml: opened %s, %i adverts\n", model_file_list_file, num_filenames );
for ( int i=0; i<num_filenames; i++ )
{
- data.pushTag("artvert", i);
+ data.pushTag("advert", i);
Artvert a;
a.model_file = data.getValue( "model_filename", "model.bmp" );
- a.name = data.getValue( "name", "unnamed" );
- a.artist = data.getValue( "artist", "unknown artist" );
a.advert = data.getValue( "advert", "unknown advert" );
- a.artvert_image_file = data.getValue( "image_filename", "artvert1.png" );
- printf(" -ml: got artvert, model file '%s'\n", a.model_file.c_str() );
- printf(" -> %s:%s:%s:%s\n", a.name.c_str(), a.artist.c_str(),
- a.advert.c_str(), a.artvert_image_file.c_str() );
- artvert_list.push_back( a );
+ int num_artverts = data.getNumTags( "artvert" );
+ printf(" -ml: got advert, model file '%s', advert '%s', %i artverts\n", a.model_file.c_str(), a.advert.c_str(), num_artverts );
+ for ( int j=0; j<num_artverts; j++ )
+ {
+ data.pushTag("artvert", j );
+ a.name = data.getValue( "name", "unnamed" );
+ a.artist = data.getValue( "artist", "unknown artist" );
+ a.artvert_image_file = data.getValue( "image_filename", "artvert1.png" );
+ printf(" %i: %s:%s:%s\n", j, a.name.c_str(), a.artist.c_str(),
+ a.artvert_image_file.c_str() );
+ artvert_list.push_back( a );
+ data.popTag();
+ }
data.popTag();
}
data.popTag();
@@ -813,11 +837,6 @@ static bool init( int argc, char** argv )
{
// add default
Artvert a;
- a.model_file = "model.bmp";
- a.name = "unnamed";
- a.artist = "unknown artist";
- a.advert = "unknown advert";
- a.artvert_image_file = "artvert1.png";
artvert_list.push_back( a );
}
@@ -875,7 +894,7 @@ static bool init( int argc, char** argv )
// load geometry
- loadOrTrainNext();
+ loadOrTrain(0);
// try to load geom cache + start the run loop
geomCalibStart(!redo_geom);
@@ -1543,9 +1562,9 @@ static void drawAugmentation()
glBindTexture(GL_TEXTURE_2D, imageID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- IplImage image = *artverts[cnt].image;
- GLenum format = IsBGR(image.channelSeq) ? GL_BGR_EXT : GL_RGBA;
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width, image.height, 0, format, GL_UNSIGNED_BYTE, image.imageData);
+ IplImage* image = artvert_list.at(current_artvert_index).getArtvertImage();
+ GLenum format = IsBGR(image->channelSeq) ? GL_BGR_EXT : GL_RGBA;
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->width, image->height, 0, format, GL_UNSIGNED_BYTE, image->imageData);
}
glEnable(GL_TEXTURE_2D);
@@ -1826,13 +1845,13 @@ void* serialThreadFunc( void* data )
while ( !serial_thread_should_exit )
{
int read = serialport_read_until(fd, buf, '\n');
- //printf("read: %s\n",buf);
+ // printf("read: %s\n",buf);
if ( (read==0) && strlen( buf ) >= 4 /*includes final \n*/ )
{
bool button_red = (buf[0]=='1');
bool button_green = (buf[1]=='1');
bool button_blue = (buf[2]=='1');
- //printf("buttons: %s %s %s", button1?"x":"-", button2?"x":"-", button3?"x":"-");
+ // printf("buttons: %s %s %s", button_red?"red":" ", button_green?"green":" ", button_blue?"blue":" ");
// bitmapped, to access all 7 press combinations
button_state =
( button_green ? BUTTON_GREEN : 0 ) |
@@ -1894,13 +1913,13 @@ static void* detectionThreadFunc( void* _data )
{
PROFILE_THIS_BLOCK("detection_thread");
- if ( next_artvert_requested )
+ if ( new_artvert_requested )
{
// no longer draw
frame_ok = false;
// go with the loading
- loadOrTrainNext();
- next_artvert_requested = false;
+ loadOrTrain(new_artvert_requested_index);
+ new_artvert_requested = false;
}
bool frame_retrieved = false;
@@ -2084,8 +2103,9 @@ void updateMenu()
// accept?
if ( menu_accept || button_state == BUTTON_GREEN )
{
-
- loadOrTrain( menu_index );
+
+ new_artvert_requested_index = menu_index;
+ new_artvert_requested = true;
menu_accept = false;
menu_is_showing = false;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,7 @@
+no: 0
+width: 640
+height: 480
+ 612.313144 0.000000 180.804427
+ 0.000000 608.772191 149.824924
+ 0.000000 0.000000 1.000000
+
@@ -0,0 +1,7 @@
+no: 0
+width: 640
+height: 480
+ 0.996974 -0.067847 -0.037953 -109.152835
+ 0.069701 0.996320 0.049881 -137.016425
+ 0.034429 -0.052375 0.998034 588.230371
+
Oops, something went wrong.

0 comments on commit e620f9b

Please sign in to comment.