Ejemplo n.º 1
0
	bool Create()
	{

		WndMaker km(this);

		km.width(280).sv(1);
		km.width( 96).sv(2);

		km.win("dialog"		,km.label("find and replace").flags(km.IWND_NO_RESIZABLE|km.IWND_NO_CLOSE|km.IWND_AUTO_FIT).sprops("icon","Find"));
			km.win("col");
				km.win("row");
					km.add("textctrl"	,km.ld(1).name("search.text_old").hint("find what?"));
					km.add("textctrl"	,km.ld(1).name("search.text_new").hint("replace with?"));
					km.win("col"		,km.ld(0).label("search_flags").flags(km.IWND_EXPAND));
						km.add("checkbox"	,km.ld(0).name("search.case").label("match case"));
						km.add("checkbox"	,km.ld(0).name("search.word").label("match word"));
						km.add("checkbox"	,km.ld(0).name("search.regexp").label("regexp"));
						//km.add("checkbox"	,km.ld(0).name("search.posix").label("posix"));
					km.end();
				km.end();
				km.win("row");
					km.add("button"		,km.ld(2).name("Btn.Find"));
					km.add("button"		,km.ld(2).name("Btn.Replace"));
					km.add("button"		,km.ld(2).name("Btn.ReplaceAll"));
				km.end();
			km.end();
		km.end();		

		return true;
	}
Ejemplo n.º 2
0
//may be more faster
//first, spectral cluster
//second, the nearest neighbor cluster or hierarchical cluster
double* twoStepCluster(const Mat& convexPoints)
{
    printf("start to cluster the convex points using two tep method ...\n");

    time_t startTime = time(0);

    int nl = convexPoints.rows;
    int k = 200;
    Kmeans km(convexPoints, k);
    //printf("centers: %d\n", km.centers.rows);
    //std::cout << "centers: \n" << km.centers << endl;
    //cout << "nums: \n";
    //cout << km.nums;
    //cout << endl;
    //spectralClustering(convexPoints, k, indices, centers);
    printf("tag 1...\n");

    //further process
    Hierarchical hc(km.centers, km.nums);
    printf("tag 2...\n");

    double* score = hc.collectScore(km.indices);
    //double* score = km.collectScore();
    printf("end of cluster the convex points using method 2...\n");
    return score;
}
Ejemplo n.º 3
0
	IMessageView(EvtCommandWindowMessage& t,wxWindow* p):Target(t),wxPanel(p, wxID_ANY, wxDefaultPosition,wxDefaultSize)
	{

		this->SetMinSize(wxSize(200,48));

		EvtManager& ec(EvtManager::current());
		ec.append(new EvtMsgError(t));
		ec.append(new EvtMsgMessage(t));
		ec.append(new EvtMsgWarning(t));
		ec.append(new EvtMsgSearch(t));

		ec.gp_beg("tb.MsgLevel");
			ec.gp_add("Msg.Error");
			ec.gp_add("Msg.Warning");
			ec.gp_add("Msg.Message");
		ec.gp_end();
		ec.gp_beg("tb.MsgSearch");
			ec.gp_add(new EvtCommandText("Msg.Search.Text"));
			ec.gp_add("Msg.Search");
		ec.gp_end();

		WndMaker km(this);
		km.row();
			km.col(WndProperty().flags(IDefs::IWND_EXPAND));
				km.add(ec["tb.MsgLevel"].cast_group()->CreateTbar(this,16),WndProperty());
				km.add("space",WndProperty().propotion(1));
				km.add(ec["tb.MsgSearch"].cast_group()->CreateTbar(this,16),WndProperty());
			km.end();
			km.add(m_pDataView=new IMessageDataView(this),WndProperty().propotion(1).flags(IDefs::IWND_EXPAND));
		km.end();

	}
int main(int argc, char** argv)
{
  ros::init(argc, argv, "KeyframeMapper");  
  ros::NodeHandle nh;
  ros::NodeHandle nh_private("~");
  ccny_rgbd::KeyframeMapper km(nh, nh_private);
  ros::spin();
  return 0;
}
int main(int argc, char** argv)
{
  ros::init(argc, argv, "RGBNavigator");
  ros::NodeHandle nh;
  ros::NodeHandle nh_private("~");
  ccny_rgbd::RGBNavigator km(nh, nh_private);
  ros::spin();
  return 0;
}
int main()
{
    while(scanf("%d\n",&n)!=EOF)
    {
        for(int i=1;i<=n;++i)gets(s[i]);
        memset(g,0,sizeof(g));
        for(int i=1;i<=n;++i)
            for(int j=1;j<=n;++j)
                if(i!=j) g[i][j]=cal(s[i],s[j]);
        km();
    }
    return 0;
}
Ejemplo n.º 7
0
int main()
{
	int a;

	while (1) {
		for (a = 0; a < P; a++)
			if (!fork())
				km();

		for (a = 0; a < P; a++)
			wait(NULL);

		usleep(200000);
	}
}
Ejemplo n.º 8
0
wxWindow* EvtOptionPage::CreatePage(wxWindow* w)
{
    WndMaker km(w);

    km.win("container");
    DoCreatePage(km);
    km.end();

    wxWindow* pw=km.get();
    m_pVald=km.vald;

    if(m_pValdGroup)
    {
        m_pValdGroup->append(m_pVald.get());
    }
    return pw;
}
Ejemplo n.º 9
0
void CAST256::setkey(std::string KEY){
    if (keyset){
        throw std::runtime_error("Error: Key has already been set.");
    }

    if ((KEY.size() != 16) && (KEY.size() != 20) && (KEY.size() != 24) && (KEY.size() != 28) && (KEY.size() != 32)){
        throw std::runtime_error("Error: Key must be 128, 160, 192, 224, or 256 bits in length.");
    }

    KEY += std::string(32 - KEY.size(), 0);
    a = toint(KEY.substr(0, 4), 256);
    b = toint(KEY.substr(4, 4), 256);
    c = toint(KEY.substr(8, 4), 256);
    d = toint(KEY.substr(12, 4), 256);
    e = toint(KEY.substr(16, 4), 256);
    f = toint(KEY.substr(20, 4), 256);
    g = toint(KEY.substr(24, 4), 256);
    h = toint(KEY.substr(28, 4), 256);

    uint32_t Cm = 0x5A827999, Mm = 0x6ED9EBA1, Cr = 19, Mr = 17;

    std::vector <uint8_t> range24_8(24, 0);
    std::vector <uint32_t> range24_32(24, 0);

    Tm.push_back(range24_32); Tr.push_back(range24_8);
    for(uint8_t x = 0; x < 8; x++){
        Tm.push_back(range24_32);
        Tr.push_back(range24_8);
    }
    for(uint8_t i = 0; i < 24; i++){
        for(uint8_t j = 0; j < 8; j++){
            Tm[j][i] = Cm;
            Cm = (Cm + Mm) & mod32;
            Tr[j][i] = Cr;
            Cr = (Cr + Mr) & 31;
        }
    }
    for(uint8_t i = 0; i < 12; i++){
        W(i << 1);
        W((i << 1) + 1);
        Kr.push_back(kr());
        Km.push_back(km());
    }

    keyset = true;
}
Ejemplo n.º 10
0
	bool Create()
	{

		WndMaker km(this);

		km.propotion(1).flags(km.IWND_EXPAND).size(540,280).sv(1);
		km.width( 96).sv(2);

		km.win("dialog"			,km.label("Webview.Script").flags(km.IWND_NO_CLOSE|km.IWND_AUTO_FIT).sprops("icon","Find"));
			km.win("row");
				km.add("stc"	,km.ld(1).name("Webview.script"));
				km.win("col"	,km.flags(km.IWND_EXPAND));
					km.add("space"	,km.propotion(1));
					km.add("button"	,km.ld(2).name("Webview.Exec"));
					km.add("button"	,km.ld(2).name("Webview.Clear"));
				km.end();
			km.end();
		km.end();		

		return true;
	}
Ejemplo n.º 11
0
int main()
	{
	scanf("%d",&n);
	m=n;
	int sum=0;
	for(int i=1;i<=n;i++)
		{
		for(int j=1;j<=n;j++)
			{
			int t;
			scanf("%d",&t);
			conn[i][++conn[i][0]]=j;
			w[i][j]=t;
			sum+=t;
			}
		}
	km();
	int ans=0;
	for(int i=1;i<=n;i++)
		ans+=w[pre[i]][i];
	printf("%d\n",sum-ans);
	
	return 0;
	}
TEST(MoveArm, goToPoseGoal)
{
  ros::NodeHandle nh;
  actionlib::SimpleActionClient<move_arm::MoveArmAction> move_arm(nh, "move_right_arm");
  boost::thread spin_thread(&spinThread);

  move_arm.waitForServer();
  ROS_INFO("Connected to server");
  move_arm::MoveArmGoal goalA;

  //getting a monitor so that we can track the configuration of the arm
  planning_environment::RobotModels rm("robot_description");
  EXPECT_TRUE(rm.loadedModels());
    
  tf::TransformListener tf;
  planning_environment::KinematicModelStateMonitor km(&rm, &tf);
  km.waitForState();
  //should have the state at this point  

  goalA.goal_constraints.set_pose_constraint_size(1);
  goalA.goal_constraints.pose_constraint[0].pose.header.stamp = ros::Time::now();
  goalA.goal_constraints.pose_constraint[0].pose.header.frame_id = "base_link";
  
  //starting configuration
  //-position [x, y, z]    = [0.77025, -.18, 0.73]
  //-rotation [x, y, z, w] = [0, -0.05, 0, 0]

  goalA.goal_constraints.pose_constraint[0].type = arm_navigation_msgs::PoseConstraint::POSITION_X 
    + arm_navigation_msgs::PoseConstraint::POSITION_Y 
    + arm_navigation_msgs::PoseConstraint::POSITION_Z
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_R 
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_P 
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_Y;
  
  goalA.goal_constraints.pose_constraint[0].link_name = "r_wrist_roll_link";
  goalA.goal_constraints.pose_constraint[0].pose.pose.position.x = 0.60;
  goalA.goal_constraints.pose_constraint[0].pose.pose.position.y = -0.25;
  goalA.goal_constraints.pose_constraint[0].pose.pose.position.z = 0.84;
    
  goalA.goal_constraints.pose_constraint[0].pose.pose.orientation.x = 0;
  goalA.goal_constraints.pose_constraint[0].pose.pose.orientation.y = 0;
  goalA.goal_constraints.pose_constraint[0].pose.pose.orientation.z = 0;
  goalA.goal_constraints.pose_constraint[0].pose.pose.orientation.w = 1.0;

  goalA.goal_constraints.pose_constraint[0].position_tolerance_above.x = 0.01;
  goalA.goal_constraints.pose_constraint[0].position_tolerance_above.y = 0.01;
  goalA.goal_constraints.pose_constraint[0].position_tolerance_above.z = 0.01;
  goalA.goal_constraints.pose_constraint[0].position_tolerance_below.x = 0.01;
  goalA.goal_constraints.pose_constraint[0].position_tolerance_below.y = 0.01;
  goalA.goal_constraints.pose_constraint[0].position_tolerance_below.z = 0.01;

  goalA.goal_constraints.pose_constraint[0].orientation_tolerance_above.x = 0.01;
  goalA.goal_constraints.pose_constraint[0].orientation_tolerance_above.y = 0.01;
  goalA.goal_constraints.pose_constraint[0].orientation_tolerance_above.z = 0.01;
  goalA.goal_constraints.pose_constraint[0].orientation_tolerance_below.x = 0.01;
  goalA.goal_constraints.pose_constraint[0].orientation_tolerance_below.y = 0.01;
  goalA.goal_constraints.pose_constraint[0].orientation_tolerance_below.z = 0.01;

  goalA.goal_constraints.pose_constraint[0].orientation_importance = 0.2;

  goalA.contacts.resize(2);
  goalA.contacts[0].links.push_back("r_gripper_l_finger_link");
  goalA.contacts[0].links.push_back("r_gripper_r_finger_link");
  goalA.contacts[0].links.push_back("r_gripper_l_finger_tip_link");
  goalA.contacts[0].links.push_back("r_gripper_r_finger_tip_link");
  
  goalA.contacts[0].depth = 0.04;
  goalA.contacts[0].bound.type = arm_navigation_msgs::Object::SPHERE;
  goalA.contacts[0].bound.dimensions.push_back(0.3);
  goalA.contacts[0].pose = goalA.goal_constraints.pose_constraint[0].pose;
  
  goalA.contacts[1].links.push_back("r_gripper_palm_link");
  goalA.contacts[1].links.push_back("r_wrist_roll_link");
  goalA.contacts[1].depth = 0.02;
  goalA.contacts[1].bound.type = arm_navigation_msgs::Object::SPHERE;
  goalA.contacts[1].bound.dimensions.push_back(0.2);
  goalA.contacts[1].pose = goalA.goal_constraints.pose_constraint[0].pose;
  
  if (nh.ok())
  {
    bool finished_within_time = false;
    move_arm.sendGoal(goalA);
    finished_within_time = move_arm.waitForResult(ros::Duration(10.0));
    
    EXPECT_TRUE(finished_within_time);
    if (!finished_within_time)
    {
      move_arm.cancelGoal();
      ROS_INFO("Timed out achieving goal A");
    }
    else
    {
      actionlib::SimpleClientGoalState state = move_arm.getState();
      ROS_INFO("Action finished: %s",state.toString().c_str());
      EXPECT_TRUE(state == actionlib::SimpleClientGoalState::SUCCEEDED);

      double dist_pose;
      double dist_angle;
      
      diffConfig(km,goalA,dist_pose,dist_angle);

      //close enough - summed tolerances
      EXPECT_TRUE(dist_pose < .005+.005+.01);
      EXPECT_TRUE(dist_angle < .005*3);

      EXPECT_TRUE(finalStateMatchesGoal(km,goalA));
    
    }
  }

  nh.setParam( "/move_right_arm/long_range_only", true);

  move_arm::MoveArmGoal goalB;
  
  //starting configuration
  //-position [x, y, z]    = [0.77025, -.18, 0.73]
  //-rotation [x, y, z, w] = [0, -0.05, 0, 0]

  goalB.goal_constraints.set_pose_constraint_size(1);
  goalB.goal_constraints.pose_constraint[0].pose.header.stamp = ros::Time::now();
  goalB.goal_constraints.pose_constraint[0].pose.header.frame_id = "base_link";
  goalB.goal_constraints.pose_constraint[0].type = arm_navigation_msgs::PoseConstraint::POSITION_X 
    + arm_navigation_msgs::PoseConstraint::POSITION_Y 
    + arm_navigation_msgs::PoseConstraint::POSITION_Z
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_R 
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_P 
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_Y;
  
  goalB.goal_constraints.pose_constraint[0].link_name = "r_wrist_roll_link";
  goalB.goal_constraints.pose_constraint[0].pose.pose.position.x = 0.60;
  goalB.goal_constraints.pose_constraint[0].pose.pose.position.y = -0.25;
  goalB.goal_constraints.pose_constraint[0].pose.pose.position.z = 0.5;
  
  goalB.goal_constraints.pose_constraint[0].pose.pose.orientation.x = 0;
  goalB.goal_constraints.pose_constraint[0].pose.pose.orientation.y = 0;
  goalB.goal_constraints.pose_constraint[0].pose.pose.orientation.z = 0;
  goalB.goal_constraints.pose_constraint[0].pose.pose.orientation.w = 1.0;
  
  goalB.goal_constraints.pose_constraint[0].position_tolerance_above.x = 0.05;
  goalB.goal_constraints.pose_constraint[0].position_tolerance_above.y = 0.05;
  goalB.goal_constraints.pose_constraint[0].position_tolerance_above.z = 0.05;
  goalB.goal_constraints.pose_constraint[0].position_tolerance_below.x = 0.05;
  goalB.goal_constraints.pose_constraint[0].position_tolerance_below.y = 0.05;
  goalB.goal_constraints.pose_constraint[0].position_tolerance_below.z = 0.05;

  goalB.goal_constraints.pose_constraint[0].orientation_tolerance_above.x = 0.05;
  goalB.goal_constraints.pose_constraint[0].orientation_tolerance_above.y = 0.05;
  goalB.goal_constraints.pose_constraint[0].orientation_tolerance_above.z = 0.05;
  goalB.goal_constraints.pose_constraint[0].orientation_tolerance_below.x = 0.05;
  goalB.goal_constraints.pose_constraint[0].orientation_tolerance_below.y = 0.05;
  goalB.goal_constraints.pose_constraint[0].orientation_tolerance_below.z = 0.05;

  goalB.goal_constraints.pose_constraint[0].orientation_importance = 0.2;

  goalB.path_constraints.set_pose_constraint_size(1);
  goalB.path_constraints.pose_constraint[0].pose.header.stamp = ros::Time::now();
  goalB.path_constraints.pose_constraint[0].pose.header.frame_id = "base_link";
  goalB.path_constraints.pose_constraint[0].type = arm_navigation_msgs::PoseConstraint::POSITION_X 
    + arm_navigation_msgs::PoseConstraint::POSITION_Y
    + arm_navigation_msgs::PoseConstraint::POSITION_Z
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_R
    + arm_navigation_msgs::PoseConstraint::ORIENTATION_P; 
//     + arm_navigation_msgs::PoseConstraint::ORIENTATION_Y;
  goalB.path_constraints.pose_constraint[0].link_name = "r_wrist_roll_link";
  goalB.path_constraints.pose_constraint[0].pose.pose.position.x = 0.60;
  goalB.path_constraints.pose_constraint[0].pose.pose.position.y = -0.25;
  goalB.path_constraints.pose_constraint[0].pose.pose.position.z = .45;
    
  goalB.path_constraints.pose_constraint[0].pose.pose.orientation.x = 0;
  goalB.path_constraints.pose_constraint[0].pose.pose.orientation.y = 0;
  goalB.path_constraints.pose_constraint[0].pose.pose.orientation.z = 0;
  goalB.path_constraints.pose_constraint[0].pose.pose.orientation.w = 1.0;

  goalB.path_constraints.pose_constraint[0].position_tolerance_above.x = 0.1;
  goalB.path_constraints.pose_constraint[0].position_tolerance_above.y = 0.1;
  goalB.path_constraints.pose_constraint[0].position_tolerance_below.x = 0.1;
  goalB.path_constraints.pose_constraint[0].position_tolerance_below.y = 0.1;
  goalB.path_constraints.pose_constraint[0].position_tolerance_above.z = 10.0;
  goalB.path_constraints.pose_constraint[0].position_tolerance_below.z = 0.1;

  goalB.path_constraints.pose_constraint[0].orientation_tolerance_above.x = 0.1;
  goalB.path_constraints.pose_constraint[0].orientation_tolerance_above.y = 0.1;
//   goalB.path_constraints.pose_constraint[0].orientation_tolerance_above.z = 0.05;
  goalB.path_constraints.pose_constraint[0].orientation_tolerance_below.x = 0.1;
  goalB.path_constraints.pose_constraint[0].orientation_tolerance_below.y = 0.1;
//   goalB.path_constraints.pose_constraint[0].orientation_tolerance_below.z = 0.05;

  goalB.path_constraints.pose_constraint[0].orientation_importance = 0.4;

  goalB.contacts.resize(2);
  goalB.contacts[0].links.push_back("r_gripper_l_finger_link");
  goalB.contacts[0].links.push_back("r_gripper_r_finger_link");
  goalB.contacts[0].links.push_back("r_gripper_l_finger_tip_link");
  goalB.contacts[0].links.push_back("r_gripper_r_finger_tip_link");
  
  goalB.contacts[0].depth = 0.04;
  goalB.contacts[0].bound.type = arm_navigation_msgs::Object::SPHERE;
  goalB.contacts[0].bound.dimensions.push_back(0.3);
  goalB.contacts[0].pose = goalB.goal_constraints.pose_constraint[0].pose;
  
  goalB.contacts[1].links.push_back("r_gripper_palm_link");
  goalB.contacts[1].links.push_back("r_wrist_roll_link");
  goalB.contacts[1].depth = 0.02;
  goalB.contacts[1].bound.type = arm_navigation_msgs::Object::SPHERE;
  goalB.contacts[1].bound.dimensions.push_back(0.2);
  goalB.contacts[1].pose = goalB.goal_constraints.pose_constraint[0].pose;
  
  if (nh.ok())
  {
    move_arm.sendGoal(goalB);

    ros::Time start_time = ros::Time::now();
    ros::Duration elapsed(0.0);

    //trying ticks in case time gets wonky
    unsigned int ticks=0;

    while(1) {
      
      bool result_during_cycle = move_arm.waitForResult(ros::Duration(.2));
      
      //got some result before time out
      if(result_during_cycle) {
        break;
      }
      
      elapsed = ros::Time::now()-start_time;

      std::cout << "Time " << elapsed.toSec() << std::endl;

      //checking if we've gone over max time - if so bail
      if(elapsed.toSec() > 10.0 || ticks++ > 50) break;

      goalB.path_constraints.pose_constraint[0].pose.pose.orientation.x = 0;
      goalB.path_constraints.pose_constraint[0].pose.pose.orientation.y = 0;

      //check that the path obeys constraints
      EXPECT_TRUE(currentStateSatisfiesPathConstraints(km,goalB));
      
    }

    if (elapsed.toSec() > 10.0)
    {
      move_arm.cancelGoal();
      ROS_INFO("Timed out achieving goal A");
      EXPECT_TRUE(elapsed.toSec() < 10.0);
    }
    else
    {
      actionlib::SimpleClientGoalState state = move_arm.getState();
      ROS_INFO("Action finished: %s",state.toString().c_str());
      EXPECT_TRUE(state == actionlib::SimpleClientGoalState::SUCCEEDED);

      double dist_pose;
      double dist_angle;
      
      diffConfig(km,goalA,dist_pose,dist_angle);

      //close enough - summed tolerances
      EXPECT_TRUE(dist_pose < .01+.01+.002);
      EXPECT_TRUE(dist_angle < .05*3);

      EXPECT_TRUE(finalStateMatchesGoal(km,goalB));
    }
  }

  ros::shutdown();
  spin_thread.join();
}
int n,s,map[200][200],from[200]={0},lx[200]={0},ly[200]={0},slack[200],vx[200]={0},vy[200]={0};int path(int v){int i,t;if(vx[v])return false;vx[v]=1;for(i=1;i<=n;i++){if(vy[i])continue;t=lx[v]+ly[i]-map[v][i];if(t==0){vy[i]=1;if(from[i]==0||path(from[i])){from[i]=v;return1;}}else if(t<slack[i]){slack[i]=t;}}return 0;}int km(){int i,j,d,ans=0;for(i=1;i<=n;i++){while(true){memset(vx,0,800);memset(vy,0,800);for(j=1;j<=n;j++)slack[j]=2000000000;if(path(i))break;d=2000000000;for(j=1;j<=n;j++){if(!vy[j]&&slack[j]<d)d=slack[j];}for(j=1;j<=n;j++){if(vx[j])lx[j]-=d;if(vy[j])ly[j]+=d;}}}for(i=1;i<=n;i++){ans+=map[from[i]][i];}return ans;}int main(){int i,j;cin>>n;for(i=1;i<=n;i++){for(j=1;j<=n;j++){cin>>map[i][j];s+=map[i][j];if(map[i][j]>lx[i])lx[i]=map[i][j];}}cout<<s-km();}
Ejemplo n.º 14
0
void spectralClustering(const Mat& feature, int k, Mat& indices, Mat& centers)
{
    //use for sparse the graph
    //so can decrease the graph complexity
    float sparseDistance;

    Mat D;
    Mat W;
    Mat L;

    int n  =  feature.rows;
    int cols  =  feature.cols;
    //weight matrix
    W.create(n, n, CV_32FC1);
    //a square and diag matrix
    D  =  Mat::zeros(n, n, CV_32FC1);
    float mean, mean_square;
    mean = mean_square = 0;

    for(int i  =  0 ; i < n; i++)
    {
        float* wdata  =  W.ptr<float>(i);
        const float* data  =  feature.ptr<float>(i);
        for(int j  =  0;  j < n; j++)
        {
            wdata[j]  =  0;
            if(i  ==  j)
            {
                wdata[j]  =  1;
                continue;
            }
            for(int k  =  0; k < cols; k ++)
                wdata[j] +=  (data[k] - feature.at<float>(j, k)) * (data[k] - feature.at<float>(j, k));
            wdata[j]  =  1/wdata[j];
            mean += wdata[j];
            mean_square += wdata[j] * wdata[j];
        }
    }
    mean = mean/(n * n);
    float delta = sqrt(mean_square/(n*n) - mean*mean);
    double min_prob = 0.01;
    const float pi = 3.14159265;
    sparseDistance = (mean - 2 * delta);

    for(int i  =  0 ; i < n; i++)
    {
        float* wdata  =  W.ptr<float>(i);
        float sum  =  0.0;
        for(int j  =  0;  j < n; j++)
        {
            if(wdata[j] < sparseDistance)
                wdata[j]  =  0;
            sum +=  wdata[j];
        }
        D.at<float>(i, i)  =  sum;
    }


    Mat eigenValues;
    Mat eigenVectors;
    //SVD factor for matrix L
    L  =  D - W;
    eigen(L, eigenValues, eigenVectors);
    //printInfo(eigenValues);
    Mat pcaResult;
    //get the last k miniest eiggenvalue rows for store in matrix pcaResult
    transpose(eigenVectors.rowRange(eigenVectors.rows - k, eigenVectors.rows), pcaResult);
    //kmeans
    Kmeans km(pcaResult, k);
    indices = km.indices;
    centers = km.centers;
}