예제 #1
0
LRESULT CFileUploaderDialog::OnGetFrobDone (WPARAM wParam, LPARAM lParam)
{
    CWMParam* pParam = (CWMParam*)wParam;

    if (true == pParam->b_Success)
    {
        s_Frob = pParam->s_Frob;

        // Get Auth URL and Open it using the Default Web Browser
        ShellExecute (NULL, _T("open"), pParam->s_AuthURL, NULL, NULL, SW_SHOWNORMAL);

        // Update UI
        ShowLoginContinueMessage ();
    }
    else
    {
        ShowOfflineMessage ();
    }

    ShowHelpText ();

    delete pParam;

    return 0;
}
예제 #2
0
LRESULT CFileUploaderDialog::OnRestoreUserDone (WPARAM wParam, LPARAM lParam)
{
    CWMParam* pParam = (CWMParam*)wParam;

    if (true == pParam->b_Success)
    {
        ShowOnlineMessage (s_Username, pParam->s_PhotosURL, pParam->s_ProfileURL, pParam->s_AvailableQuota);

        // Set Available Photo Set Status
        m_AvailableSetsListCtrl.SetPro (pParam->b_Pro);
        m_AvailableSetsListCtrl.SetRemainingSetCount (pParam->i_RemainingSetCount);
        m_AvailableSetsListCtrl.SetUserSignedIn (true);

        while (false == pParam->lst_PhotoSetInfo.empty ())
        {
            map_PhotoSetInfoByName.insert (make_pair (pParam->lst_PhotoSetInfo.front ()->s_Name, pParam->lst_PhotoSetInfo.front ()));

            pParam->lst_PhotoSetInfo.pop_front ();
        }

        b_SignedIn = true;
    }
    else
    {
        ShowOfflineMessage ();

        b_SignedIn = false;
    }

    ShowHelpText ();

    delete pParam;

    return 0;
}
예제 #3
0
void CFileUploaderDialog::OnButtonSignOut (void)
{
    // Update UI
    ShowOfflineMessage ();
    ShowHelpText ();

    // Clean PhotoSet Details
    CPhotoSetInfo::PhotoSetInfoByName_map_t::iterator itePhotoSetInfo;
    CPhotoSetInfo::PhotoSetInfoByName_map_t::iterator iteStartPhotoSetInfo = map_PhotoSetInfoByName.begin ();
    CPhotoSetInfo::PhotoSetInfoByName_map_t::iterator iteEndPhotoSetInfo = map_PhotoSetInfoByName.end ();

    for (itePhotoSetInfo = iteStartPhotoSetInfo; itePhotoSetInfo != iteEndPhotoSetInfo; ++itePhotoSetInfo)
        delete itePhotoSetInfo->second;

    map_PhotoSetInfoByName.clear ();

    // Clear Selected Photo Sets of Images
    CImageDetails::ImageDetailsByItemIndex_map_t::iterator iteImageDetails;
    CImageDetails::ImageDetailsByItemIndex_map_t::iterator iteStartImageDetails = map_ImageDetailsByItemIndex.begin ();
    CImageDetails::ImageDetailsByItemIndex_map_t::iterator iteEndImageDetails = map_ImageDetailsByItemIndex.end ();

    for (iteImageDetails = iteStartImageDetails; iteImageDetails != iteEndImageDetails; ++iteImageDetails)
        iteImageDetails->second->set_SelectedSets.clear ();

    // Set Available Photo Set Status
    m_AvailableSetsListCtrl.SetUserSignedIn (false);

    // Update Selected Image Details
    int iItemIndex = m_ImageListCtrl.GetNextItem (-1, LVNI_SELECTED);
    if (iItemIndex != -1)
        ShowImageDetails (iItemIndex);

    // Clear User Profile Data
    CRegKey regKey;
    LONG    lResult;

    lResult = regKey.Create (HKEY_CURRENT_USER, _T("Software\\WSO2\\WeSCli\\FlickrUploader"));

    if (ERROR_SUCCESS == lResult)
    {
        // Username
        regKey.DeleteValue (_T("Username"));
        // NSID
        regKey.DeleteValue (_T("NSID"));
        // Token
        regKey.DeleteValue (_T("Token"));
        // WSFCHome
        regKey.DeleteValue (_T("WSFCHome"));
    }

    b_SignedIn = false;
}
//-----------------------------------【main( )函数】--------------------------------------------  
//   描述:控制台应用程序的入口函数,我们的程序从这里开始执行  
//-----------------------------------------------------------------------------------------------  
int main( int argc, char** argv )  
{  
	//【0】改变console字体颜色      
	system("color 2F");      

	//【0】显示帮助文字    
	ShowHelpText( );    

	//【1】载入源图片并显示  
	Mat srcImage1 = imread("C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg", 1 );  
	Mat srcImage2 = imread("C:\\Users\\Public\\Pictures\\Sample Pictures\\Koala.jpg", 1 );  
	if( !srcImage1.data || !srcImage2.data )//检测是否读取成功  
	{ printf("读取图片错误,请确定目录下是否有imread函数指定名称的图片存在~! \n"); return false; }   
	imshow("原始图1",srcImage1);  
	imshow("原始图2",srcImage2);  

	//【2】定义需要用到的变量和类  
	int minHessian = 400;//定义SURF中的hessian阈值特征点检测算子  
	SurfFeatureDetector detector( minHessian );//定义一个SurfFeatureDetector(SURF) 特征检测类对象  
	std::vector<KeyPoint> keypoints_1, keypoints_2;//vector模板类是能够存放任意类型的动态数组,能够增加和压缩数据  

	//【3】调用detect函数检测出SURF特征关键点,保存在vector容器中  
	detector.detect( srcImage1, keypoints_1 );  
	detector.detect( srcImage2, keypoints_2 );  

	//【4】绘制特征关键点  
	Mat img_keypoints_1; Mat img_keypoints_2;  
	drawKeypoints( srcImage1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DEFAULT );  
	drawKeypoints( srcImage2, keypoints_2, img_keypoints_2, Scalar::all(-1), DrawMatchesFlags::DEFAULT );  

	//【5】显示效果图  
	imshow("特征点检测效果图1", img_keypoints_1 );  
	imshow("特征点检测效果图2", img_keypoints_2 );  

	waitKey(0);  
	return 0;  
}  
예제 #5
0
//-----------------------------------【main( )函数】------------------------------------------------------------------------------  
//      描述:控制台应用程序的入口函数,我们的程序从这里开始  
//--------------------------------------------------------------------------------------------------------------------------------  
int main(int agrc, char** agrv)
{


	initMain();//初始化

	//载入原图  
	g_srcImage = imread(".\\sourcePicture\\3.bmp");

	//添加噪音
	if (noice)
	{
		salt(g_srcImage);
		imwrite("./output/noice.bmp", g_gradBmp);
	}

	//定义一个Mat类型并给其设定ROI区域  
	//g_srcImage = g_srcImage(Rect(0, 0, 250, 250));

	//判断是否读取成功
	if (!g_srcImage.data)
	{
		cout << "读取图片srcImage时出错!\n";
		return false;
	}


	//将原图转换为灰度图  
	cvtColor(g_srcImage, g_srcGrayImage, CV_BGR2GRAY);

	ShowHelpText(g_srcGrayImage);

	//histGram(g_srcGrayImage);
	Edge edge1;
	Edge edge(g_srcGrayImage);//传值初始化
	edge.Init();//深入初始化
	//edge.edgeDection(1,NULL);

	//创建Canny检测的tracebar
	namedWindow("Canny检测");
	//namedWindow("listk1"); namedWindow("listk1&&listk2");
	createTrackbar("参数值:", "Canny检测", &g_cannyLowThreshold, 160, edge.on_Canny);
	namedWindow("g_mergImg");//, CV_WINDOW_NORMAL
	//createTrackbar("梯度:", "g_mergImg", &TH, 80, edge.edgeDection);	
	//createTrackbar("相似度:", "g_mergImg", &TH1, 40, edge.edgeDection);
	//createTrackbar("相似度:", "g_edge[1]", &g_di, 80, edge.listK);
	edge.edgeDection();
	//edge.edgeDection1();
	g_srcGrayImage.convertTo(g_srcGrayImage, CV_32F);

	if (xls)
	{
		edge.outXls(g_srcGrayImage, "./output/gray.xls");
		//outxlsInt(g_biGrad, "./output/bigrad.xls");
	}

	//cout << g_ltedge << endl;
	//将原图转换为灰度图
	//g_dstImage.convertTo(g_dstImage, CV_8UC1);
	//namedWindow("dst");
	//imshow("dst", g_dstImage);
	//显示梯度图片

	g_srcGrad.convertTo(g_gradBmp, CV_8UC1);
	imshow("梯度图", g_gradBmp);
	imwrite("./output/grad.bmp", g_gradBmp);





	//轮询获取按键信息,若按下Q,程序退出  
	while ((char(waitKey(1)) != 'q')) {}
	return 0;
}
예제 #6
0
void CFileUploaderDialog::OnTimer (UINT_PTR nIDEvent)
{
    if (nIDEvent == TID_USER_PROFILE_RESTORE) // Restore User Profile
    {
        KillTimer (nIDEvent);

        // Read Profile from the Registry
        CRegKey regKey;
        LONG    lResult;

        lResult = regKey.Open (HKEY_CURRENT_USER, _T("Software\\WSO2\\WeSCli\\FlickrUploader"));

        if (ERROR_SUCCESS == lResult)
        {
            // Username
            TCHAR zUsername[100];
            ULONG nCharsUsername = 100;
            lResult = regKey.QueryStringValue (_T("Username"), zUsername, &nCharsUsername);

            if (ERROR_SUCCESS == lResult)
                s_Username = zUsername;

            // NSID
            TCHAR zNSID[50];
            ULONG nCharsNSID = 50;
            lResult = regKey.QueryStringValue (_T("NSID"), zNSID, &nCharsNSID);

            if (ERROR_SUCCESS == lResult)
                s_NSID = zNSID;

            // Token
            TCHAR zToken[50];
            ULONG nCharsToken = 50;
            lResult = regKey.QueryStringValue (_T("Token"), zToken, &nCharsToken);

            if (ERROR_SUCCESS == lResult)
                s_Token = zToken;

            // WSF/C Home
            TCHAR zWSFCHome[MAX_PATH];
            ULONG nCharsWSFCHome = MAX_PATH;
            lResult = regKey.QueryStringValue (_T("WSFCHome"), zWSFCHome, &nCharsWSFCHome);

            if (ERROR_SUCCESS == lResult)
                s_WSFCHome = zWSFCHome;
        }

        if ((s_Token != "") && (s_WSFCHome != "")) // Restore Saved Profile
        {
            ShowWaitAnimation ();

            o_FlickrClient.RestoreUser (s_WSFCHome, s_Token, s_NSID, this);
        }
        else // Profile not Saved
        {
            // Update UI
            ShowOfflineMessage ();
            ShowHelpText ();

            b_SignedIn = false;
        }
    }

    CDialog::OnTimer (nIDEvent);
}
예제 #7
0
BOOL CFileUploaderDialog::OnInitDialog (void)
{
    CDialog::OnInitDialog ();

    // Initialize FlickrClient
    o_FlickrClient.SetPhotoSetInfo (&map_PhotoSetInfoByName);

    // Add Items to the System Menu
    CMenu* pSysMenu = GetSystemMenu (FALSE);
    if (pSysMenu != NULL)
    {
        pSysMenu->AppendMenu (MF_SEPARATOR);
        pSysMenu->AppendMenu (MF_STRING, IDM_SETTINGS, _T("&Settings ..."));
    }

    // Set System Icons
    SetIcon (hico_FlickrPal16, FALSE);
    SetIcon (hico_FlickrPal32, TRUE);

    // Create Wait Animation
    CRect oWaitAnimationRect;
    GetDlgItem (IDC_WAIT_ANIMATION_RECT)->GetWindowRect (oWaitAnimationRect);
    ScreenToClient (oWaitAnimationRect);

    m_WaitAnimation.Create (NULL,
                            _T("WaitAnimation"),
                            WS_CHILD,
                            oWaitAnimationRect,
                            this,
                            IDC_WAIT_ANIMATION_RECT);

    // Create Username Ctrl
    CRect oUsernameTextRect;
    GetDlgItem (IDC_USERNAME_RECT)->GetWindowRect (oUsernameTextRect);
    ScreenToClient (oUsernameTextRect);

    m_UsenameText.Create (NULL,
                          _T("UsernameText"),
                          WS_CHILD,
                          oUsernameTextRect,
                          this,
                          IDC_USERNAME_RECT);

    m_UsenameText.Init (RGB (0, 200, 0));

    // Create User Photos URL
    CRect oUserPhotosURLRect;
    GetDlgItem (IDC_USER_PHOTOS_URL_RECT)->GetWindowRect (oUserPhotosURLRect);
    ScreenToClient (oUserPhotosURLRect);

    m_UserPhotosURLCtrl.Create (NULL,
                                _T("UserPhotosURL"),
                                WS_CHILD,
                                oUserPhotosURLRect,
                                this,
                                IDC_USER_PHOTOS_URL_RECT);

    // Create User Profile URL
    CRect oUserProfileURLRect;
    GetDlgItem (IDC_USER_PROFILE_URL_RECT)->GetWindowRect (oUserProfileURLRect);
    ScreenToClient (oUserProfileURLRect);

    m_UserProfileURLCtrl.Create (NULL,
                                 _T("UserProfileURL"),
                                 WS_CHILD,
                                 oUserProfileURLRect,
                                 this,
                                 IDC_USER_PROFILE_URL_RECT);

    // Create Available Quota Ctrl
    CRect oAvailableQuotaRect;
    GetDlgItem (IDC_AVAILABLE_QUOTA_RECT)->GetWindowRect (oAvailableQuotaRect);
    ScreenToClient (oAvailableQuotaRect);

    m_AvailableQuotaText.Create (NULL,
                                 _T("AvailableQuotaText"),
                                 WS_CHILD,
                                 oAvailableQuotaRect,
                                 this,
                                 IDC_AVAILABLE_QUOTA_RECT);

    m_AvailableQuotaText.Init (RGB (0, 100, 50), true);

    // Create Image Thumbnail List View
    CRect rect;
    CWnd* pListCtrlRef = GetDlgItem (IDC_IMAGE_THUMBNAIL_LC_REF);
    pListCtrlRef->GetWindowRect (rect);
    ScreenToClient (rect);

    m_ImageListCtrl.Create (WS_CHILD | WS_VSCROLL | LVS_ICON | WS_VISIBLE | LVS_SINGLESEL, rect, this, IDC_IMAGE_THUMBNAIL_LC_REF);

    // Show Thumbnails
    m_ImageListCtrl.ShowImageThumbnails (lst_FileName);

    // Store Image Data
    int iItemIndex = 0;
    while (lst_FileName.empty () == false)
    {
        CString sFileName = lst_FileName.front ();

        CImageDetails* pImageDetails = new CImageDetails;

        // Set File Name
        pImageDetails->s_FileName = sFileName;
        // Set File Name as the Title
        CString sTitle = sFileName.Right (sFileName.GetLength() - sFileName.ReverseFind ('\\') - 1); // With the extension
        pImageDetails->s_Title = sTitle.Left (sTitle.Find ('.')); // Without the extension
        // Set File Size
        pImageDetails->s_FileSize = GetFileSize (sFileName);

        map_ImageDetailsByItemIndex.insert (make_pair (iItemIndex++, pImageDetails));

        lst_FileName.pop_front ();
    }

    // Initialize Only Me Radio Button
    m_OnlyMeRadioButton.SetEnable (true);
    m_OnlyMeRadioButton.SetFamilyCheckBox (&m_FamilyCheckBox);
    m_OnlyMeRadioButton.SetFriendsCheckBox (&m_FriendsCheckBox);

    // Initialize Anyone Radio Button
    m_AnyoneRadioButton.SetEnable (false);
    m_AnyoneRadioButton.SetFamilyCheckBox (&m_FamilyCheckBox);
    m_AnyoneRadioButton.SetFriendsCheckBox (&m_FriendsCheckBox);

    // Initialize Sets Lists
    m_SetsImageList.Create (16, 16, ILC_COLOR32 | ILC_MASK, 0, 4);
    CBitmap bmListItem; // Existing Item
    bmListItem.LoadBitmap (IDB_BITMAP_SET_LIST_ITEM);
    m_SetsImageList.Add (&bmListItem, RGB(0, 0, 0));

    CBitmap bmListItemNew; // New Item
    bmListItemNew.LoadBitmap (IDB_BITMAP_SET_LIST_ITEM_NEW);
    m_SetsImageList.Add (&bmListItemNew, RGB(0, 0, 0));

    m_AvailableSetsListCtrl.SetImageList (&m_SetsImageList, LVSIL_SMALL);
    m_AvailableSetsListCtrl.InsertColumn (0, _T(""), 0, 150);
    m_AvailableSetsListCtrl.SetButton ((CButton*)GetDlgItem (IDC_BUTTON_ADD_SET));
    m_AvailableSetsListCtrl.SetPhotoSetInfo (&map_PhotoSetInfoByName);

    m_SelectedSetsListCtrl.SetImageList (&m_SetsImageList, LVSIL_SMALL);
    m_SelectedSetsListCtrl.InsertColumn (0, _T(""), 0, 150);
    m_SelectedSetsListCtrl.SetButton ((CButton*)GetDlgItem (IDC_BUTTON_REMOVE_SET));

    // Initialize Animate Control
    TCHAR zWindowsDirectory [MAX_PATH];
    GetWindowsDirectory (zWindowsDirectory, MAX_PATH);

    CString sAnimationFileName = zWindowsDirectory;
    if (sAnimationFileName[sAnimationFileName.GetLength () - 1] != '\\')
        sAnimationFileName+= '\\';
    sAnimationFileName+= "upload.avi";

    m_AnimateCtrl.Open (sAnimationFileName);

    // Show Offline Message
    ShowOfflineMessage ();

    // Set Default Values
    m_OnlyMeRadioButton.SetCheck (TRUE);
    m_SafetyLevelCombo.SetCurSel (0);
    m_HiddenCombo.SetCurSel (0);
    m_ContentTypeCombo.SetCurSel (0);

    // Disable Image Controls by Default
    EnableImageControls (FALSE);

    // Show Initial Help Message
    ShowHelpText ();

    // Create User Profile Restore Timer
    SetTimer (TID_USER_PROFILE_RESTORE, 10, NULL);

    return TRUE;
}
예제 #8
0
void CFileUploaderDialog::ShowImageDetails (int _iItemIndex)
{
    CImageDetails::ImageDetailsByItemIndex_map_t::iterator ite;
    ite = map_ImageDetailsByItemIndex.find (_iItemIndex);

    if (ite != map_ImageDetailsByItemIndex.end ())
    {
        CImageDetails* pImageDetails = ite->second;

        m_TitleEdit.SetWindowText (pImageDetails->s_Title);
        m_DescriptionEdit.SetWindowText (pImageDetails->s_Description);
        m_TagsEdit.SetWindowText (pImageDetails->s_Tags);
        m_OnlyMeRadioButton.SetCheck (pImageDetails->b_OnlyMe);
        m_FamilyCheckBox.SetCheck (pImageDetails->b_Family);
        m_FriendsCheckBox.SetCheck (pImageDetails->b_Friends);
        m_AnyoneRadioButton.SetCheck (pImageDetails->b_Anyone);
        m_SafetyLevelCombo.SetCurSel (pImageDetails->i_SafetyLevel - 1);
        m_HiddenCombo.SetCurSel (pImageDetails->i_Hidden - 1);
        m_ContentTypeCombo.SetCurSel (pImageDetails->i_ContentType - 1);

        // Refresh Available Sets List
        m_AvailableSetsListCtrl.DeleteAllItems ();

        CPhotoSetInfo::PhotoSetInfoByName_map_t::iterator itePhotoSetInfo;
        CPhotoSetInfo::PhotoSetInfoByName_map_t::iterator itePhotoSetInfoStart = map_PhotoSetInfoByName.begin ();
        CPhotoSetInfo::PhotoSetInfoByName_map_t::iterator itePhotoSetInfoEnd = map_PhotoSetInfoByName.end ();

        for (itePhotoSetInfo = itePhotoSetInfoStart; itePhotoSetInfo != itePhotoSetInfoEnd; ++itePhotoSetInfo)
        {
            if (pImageDetails->set_SelectedSets.find (itePhotoSetInfo->first) == pImageDetails->set_SelectedSets.end ()) // Photo Set not Selected
            {
                int iImageIndex = itePhotoSetInfo->second->b_New ? 1 : 0;

                m_AvailableSetsListCtrl.InsertItem (m_AvailableSetsListCtrl.GetItemCount (), itePhotoSetInfo->first, iImageIndex);
            }
        }

        // Refresh Selected Sets List
        m_SelectedSetsListCtrl.DeleteAllItems ();

        CImageDetails::PhotoSetName_set_t::iterator itePhotoSetName;
        CImageDetails::PhotoSetName_set_t::iterator itePhotoSetNameStart = pImageDetails->set_SelectedSets.begin ();
        CImageDetails::PhotoSetName_set_t::iterator itePhotoSetNameEnd = pImageDetails->set_SelectedSets.end ();

        for (itePhotoSetName = itePhotoSetNameStart; itePhotoSetName != itePhotoSetNameEnd; ++itePhotoSetName)
        {
            CPhotoSetInfo::PhotoSetInfoByName_map_t::iterator itePhotoSetInfo;
            itePhotoSetInfo = map_PhotoSetInfoByName.find (*itePhotoSetName);

            if (itePhotoSetInfo != map_PhotoSetInfoByName.end ())
            {
                int iImageIndex = itePhotoSetInfo->second->b_New ? 1 : 0;

                m_SelectedSetsListCtrl.InsertItem (m_SelectedSetsListCtrl.GetItemCount (), *itePhotoSetName, iImageIndex);
            }
        }

        m_FileName.SetWindowText (pImageDetails->s_FileName);
        m_FileSize.SetWindowText (pImageDetails->s_FileSize);

        ShowHelpText ();

        //RedrawWindow ();
    }
}
예제 #9
0
LRESULT CFileUploaderDialog::OnCreateUserDone (WPARAM wParam, LPARAM lParam)
{
    CWMParam* pParam = (CWMParam*)wParam;

    if (true == pParam->b_Success)
    {
        s_Username = pParam->s_Username;
        s_NSID = pParam->s_NSID;
        s_Token = pParam->s_Token;

        ShowOnlineMessage (s_Username, pParam->s_PhotosURL, pParam->s_ProfileURL, pParam->s_AvailableQuota);

        // Set Available Photo Set Status
        m_AvailableSetsListCtrl.SetPro (pParam->b_Pro);
        m_AvailableSetsListCtrl.SetRemainingSetCount (pParam->i_RemainingSetCount);
        m_AvailableSetsListCtrl.SetUserSignedIn (true);

        // Get Photo Set Names
        while (false == pParam->lst_PhotoSetInfo.empty ())
        {
            map_PhotoSetInfoByName.insert (make_pair (pParam->lst_PhotoSetInfo.front ()->s_Name, pParam->lst_PhotoSetInfo.front ()));

            pParam->lst_PhotoSetInfo.pop_front ();
        }

        // Update Selected Image Details
        int iItemIndex = m_ImageListCtrl.GetNextItem (-1, LVNI_SELECTED);
        if (iItemIndex != -1)
            ShowImageDetails (iItemIndex);

        // Save User Profile Data
        CRegKey regKey;
        LONG    lResult;

        lResult = regKey.Create (HKEY_CURRENT_USER, _T("Software\\WSO2\\WeSCli\\FlickrUploader"));

        if (ERROR_SUCCESS == lResult)
        {
            // Username
            regKey.SetStringValue (_T("Username"), s_Username);
            // NSID
            regKey.SetStringValue (_T("NSID"), s_NSID);
            // Token
            regKey.SetStringValue (_T("Token"), s_Token);
        }

        b_SignedIn = true;
    }
    else
    {
        ShowOfflineMessage ();

        b_SignedIn = false;
    }

    ShowHelpText ();

    delete pParam;

    return 0;
}