Permalink
Browse files

Merge branch 'master' into thread_mp

  • Loading branch information...
2 parents c84be65 + 25d0dfc commit afba89c786abfca0d0e6637402ea3f4040542d62 Sameep Tandon committed Jun 17, 2011
View
@@ -1,19 +1,20 @@
MACHINE= $(shell uname -s)
-HOSTNAME=-D$(shell uname -n | sed 's/-/_/g')
+HOSTNAME=-D$(shell uname -n | sed 's/-/_/g' | sed 's/\./_/g')
+UTILS_DIR = ../utils/
ifeq ($(MACHINE),Darwin)
- LIBS = -L/usr/lib/ -lglut -lgle -L/usr/local/lib/x86_64
+ LIBS = -L/usr/lib/ -lglut -lgle
COMPILEFLAG=-DMAC
LDFLAG=$(COMPILEFLAG) -L"/System/Library/Frameworks/OpenGL.framework/Libraries" -L"/System/Library/Frameworks/GLUT.framework" -framework GLUT -framework OpenGL -lGL -lGLU -L/usr/X11R6/lib
+ INCLUDES = -I/usr/local/include/ -I/usr/include/ -I $(UTILS_DIR) -I/opt/local/include/eigen2/ -I/opt/local/include/
else
LIBS = -L/usr/lib/ -lglut -lgle
+ ILNCLUDES = -I/usr/local/include/ -I/usr/include/ -I $(UTILS_DIR) -I/usr/include/eigen2
COMPILEFLAG=
LDFLAG=
endif
VISION_LIBS = -L/usr/local/lib/ -lcxcore -lcv -lhighgui -lcvaux -lml -lm -L/usr/lib/ -lPvAPI -lrt
-UTILS_DIR = ../utils/
-INCLUDES = -I/usr/local/include/ -I/usr/include/ -I $(UTILS_DIR) -I/usr/include/eigen2
VISION_INCLUDES = -I/usr/local/include/opencv/
SOCKETS_DIR = ../utils/sockets/
# OPT_COMP =
View
Binary file not shown.
@@ -19,6 +19,8 @@
#define NUM_CPU_THREADS 12
#elif surgical3
#define NUM_CPU_THREADS 6
+#elif surgical_macbook
+ #define NUM_CPU_THREADS 4
#else
#define NUM_CPU_THREADS 1
#endif
View
@@ -1,12 +1,12 @@
MACHINE= $(shell uname -s)
-HOSTNAME=-D$(shell uname -n | sed 's/-/_/g')
+HOSTNAME=-D$(shell uname -n | sed 's/-/_/g' | sed 's/\./_/g')
UTILS_DIR = ../utils/
ifeq ($(MACHINE),Darwin)
- LIBS = -L/usr/local/lib/x86_64 -L/usr/lib/ -lglut -lgle -lboost_program_options-mt -lgsl -lgslcblas -llshkit
+ LIBS = -L/usr/lib/ -lglut -lgle -lgsl -lgslcblas -llshkit -L/opt/local/lib/ -lboost_program_options-mt
COMPILEFLAG=-DMAC
LDFLAG=$(COMPILEFLAG) -L"/System/Library/Frameworks/OpenGL.framework/Libraries" -L"/System/Library/Frameworks/GLUT.framework" -framework GLUT -framework OpenGL -lGL -lGLU -L/usr/X11R6/lib -L/opt/local/lib -lopencv_core -lopencv_highgui
- INCLUDES = -I/usr/local/include/ -I $(UTILS_DIR) -I/usr/local/include/eigen2/ -I/usr/include/boost/ -I/usr/local/include/lshkit/ -I/opt/local/include/opencv/
+ INCLUDES = -I/usr/local/include/ -I $(UTILS_DIR) -I/opt/local/include/eigen2/ -I/opt/local/include/ -I/opt/local/include/lshkit/ -I/opt/local/include/opencv/
else
LIBS = -L/usr/local/lib/ -lcxcore -lcv -lhighgui -lcvaux -lml -lm -L/usr/lib/ -lglut -lgle -llshkit -lgsl -lgslcblas -lboost_program_options-mt
COMPILEFLAG=
@@ -23,7 +23,7 @@
#include "linearization_utils.h"
#include "iterative_control.h"
#include "trajectory_follower.h"
-#include "../../utils/clock.h"
+#include "../utils/clock.h"
@@ -21,7 +21,7 @@
#include "linearization_utils.h"
#include "iterative_control.h"
#include "trajectory_follower.h"
-#include "../../utils/clock.h"
+#include "../utils/clock.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
@@ -21,7 +21,7 @@
#include "linearization_utils.h"
#include "iterative_control.h"
#include "trajectory_follower.h"
-#include "../../utils/clock.h"
+#include "../utils/clock.h"
#include <opencv/cv.h>
#include <opencv/highgui.h>
@@ -26,7 +26,7 @@
#define MAX_LENGTH_VIS 67
-#define FAKEIMS_FILE "saved_threads/test_trajectories"
+#define FAKEIMS_FILE "saved_threads/knots_coils_crossings"
#define IMAGE_SAVE_BASE_OPENGL "saved_threads/saved_opengl"
//#define TRY_ALL false
@@ -35,7 +35,7 @@ vector<Thread> saved_trajectory;
#define NUM_THREADS_DISPLAY 2
-#define NUM_THREADS 60
+#define NUM_THREADS 10
enum DisplayedThreads {optimizedThread, truthThread};
// import most common Eigen types
@@ -151,11 +151,17 @@ double seconds_elapsed()
return ((double) end_time - start_time)/((double) CLOCKS_PER_SEC);
}
-/* Difference between 2 threads based on l2 norm of distance between vertices.
+/*
+ * Difference between 2 threads based on l2 norm of distance between vertices.
* Requires that 2 threads be the same length.
*/
double thread_difference(Thread* t1, Thread* t2)
{
+ if (t1->_thread_pieces.size() != t2->_thread_pieces.size())
+ {
+ cout << "warning: threads not of same length (thread_difference)" << std::endl;
+ return -1;
+ }
double difference = 0;
int length = t1->_thread_pieces.size();
for (int i = 0; i < length; i++)
@@ -342,7 +348,7 @@ void processNormalKeys(unsigned char key, int x, int y)
/* Run through all threads, generate guess, save image in test_images */
else if (key == 'p')
{
- thread_ind = 0;
+ thread_ind = -1;
while (true) {
next_thread();
DrawStuff();
@@ -357,7 +363,7 @@ void processNormalKeys(unsigned char key, int x, int y)
printf("thread %2d |\t runtime (s): %05.3f | difference: %05.3f\n", thread_ind, generation_times[thread_ind], thread_differences[thread_ind]);
DrawStuff();
save_opengl_image();
- if (thread_ind == 59) break;
+ if (thread_ind == NUM_THREADS-1) break;
}
cout << endl << "-------------------" << endl;
cout << "PERFORMANCE SUMMARY" << endl;
@@ -795,9 +801,10 @@ void addThreadDebugInfo()
void save_opengl_image()
{
+
const int IMG_COLS_TOTAL = WINDOW_WIDTH;
const int IMG_ROWS_TOTAL = WINDOW_HEIGHT;
- //playback and save images
+
Mat img(WINDOW_WIDTH, WINDOW_HEIGHT, CV_8UC3);
vector<Mat> img_planes;
split(img, img_planes);
@@ -818,9 +825,10 @@ void save_opengl_image()
merge(img_planes, img);
flip(img, img, 0);
- char im_name[256];
- const char*prefix = USE_DISTANCE_METRIC ? "distance" : "energy";
- sprintf(im_name, "test_images/%s_thread%d_%d.jpg", prefix, NUM_HYPOTHS_MAX, thread_ind);
+ char im_name[256];
+ const char* prefixes[] = {"visual", "energy", "distance"};
+ sprintf(im_name, "test_images/%s_thread_knots%d_%d.jpg",
+ prefixes[CURRENT_METRIC], NUM_HYPOTHS_MAX, thread_ind);
cout << "saving " << im_name << "...\n";
imwrite(im_name, img);
waitKey(1);
@@ -365,19 +365,17 @@ double Thread_Hypoth::calculate_visual_energy()
*/
void Thread_Hypoth::calculate_score()
{
- const double DISTANCE_COEFF = 0.1;
double visual_energy = calculate_visual_energy();
- if (!USE_DISTANCE_METRIC) {
+ if (CURRENT_METRIC == VISUAL_ONLY)
+ _score = visual_energy;
+ else if (CURRENT_METRIC == VISUAL_ENERGY)
+ {
double energy = calculate_energy();
-// cout << "calculate_score | visual energy: " << visual_energy << "\tenergy: " << energy << std::endl;
_score = visual_energy + energy;
}
- else {
- double distance = 0;
- distance += distance_from_energy_minimal_configuration();
- distance = DISTANCE_COEFF*distance;
- //cout << "calculate_score | visual energy: " << visual_energy << "\tdistance: " << distance << std::endl;
- _score = visual_energy + DISTANCE_COEFF*distance;
+ else { // CURRENT_METRIC = VISUAL_DISTANCE
+ _score = visual_energy +
+ DISTANCE_COEFF*distance_from_energy_minimal_configuration();
}
}
@@ -16,7 +16,9 @@
#define NUM_HYPOTHS_MAX 20
-#define USE_DISTANCE_METRIC true
+#define CURRENT_METRIC 0
+#define DISTANCE_COEFF 0.1
+enum Metrics {VISUAL_ONLY, VISUAL_ENERGY, VISUAL_DISTANCE};
class Thread_Vision;

0 comments on commit afba89c

Please sign in to comment.