2020년 1월 2일 목요일

[Linux]우분투 GPG 공개키 인증 오류, 공개키 서버등록

sudo apt-get updata && sudo apt-get upgrade 시

아래와 같은 문제 발생
-----------------------------------------------------------------------------------
USERNAME@USERNAME-pc:~$ sudo apt-get update
기존:1 http://packages.osrfoundation.org/gazebo/ubuntu xenial InRelease
기존:3 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu xenial InRelease          
기존:4 http://kr.archive.ubuntu.com/ubuntu xenial InRelease                           
받기:2 http://packages.ros.org/ros/ubuntu xenial InRelease [4,678 B]                  
받기:5 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB]           
오류:2 http://packages.ros.org/ros/ubuntu xenial InRelease                            
  다음 서명들은 공개키가 없기 때문에 인증할 수 없습니다: NO_PUBKEY F42ED6FBAB17C654
받기:6 http://kr.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]          
받기:7 http://kr.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB]        
내려받기 330 k바이트, 소요시간 2초 (156 k바이트/초)
패키지 목록을 읽는 중입니다... 완료
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: http://packages.ros.org/ros/ubuntu xenial InRelease: 다음 서명들은 공개키가 없기 때문에 인증할 수 없습니다: NO_PUBKEY F42ED6FBAB17C654
W: http://packages.ros.org/ros/ubuntu/dists/xenial/InRelease 파일을 받는데 실패했습니다  다음 서명들은 공개키가 없기 때문에 인증할 수 없습니다: NO_PUBKEY F42ED6FBAB17C654
W: Some index files failed to download. They have been ignored, or old ones used instead.
--------------------------------------------------------------------------------------

해결방법

$ gpg --keyserver keyserver.ubuntu.com --recv F42ED6FBAB17C654
 
$ gpg --export --armor F42ED6FBAB17C654 | sudo apt-key add -
 
OK
 


더 알아보기는 GPG 구글링 고고
 

2016년 4월 25일 월요일

[MFC] How to delete an Icon of toolbar

How to delete an Icon of toolbar?
Delete button cannot remove icon itself.
The way to remove the icon of toolbar is: "Just drag and drop" the icon in toolbar to out of boundary of toolbar.

2016년 3월 14일 월요일

[PCL] Point cloud library install on window 8, msvc2010

1. Download and install files: http://pointclouds.org/downloads/

2. Add environmental variable PATH in MyPC 

3. Open VS 2010

4. Add include directories in Project properties
C:\Program Files\PCL 1.6.0\include\pcl-1.6;
C:\Program Files\PCL 1.6.0\3rdParty\Boost\include;
C:\Program Files\PCL 1.6.0\3rdParty\Eigen\include;
C:\Program Files\PCL 1.6.0\3rdParty\FLANN\include;
C:\Program Files\PCL 1.6.0\3rdParty\Qhull\include;
C:\Program Files\PCL 1.6.0\3rdParty\VTK\include\vtk-5.8;

5. Add library directories in Project properties
C:\Program Files\PCL 1.6.0\lib;
C:\Program Files\PCL 1.6.0\3rdParty\Boost\lib;
C:\Program Files\PCL 1.6.0\3rdParty\FLANN\lib;
C:\Program Files\PCL 1.6.0\3rdParty\Qhull\lib;
C:\Program Files\PCL 1.6.0\3rdParty\VTK\lib\vtk-5.8;

6. Add libraries 
#pragma comment(lib, "pcl_apps_debug.lib")
#pragma comment(lib, "pcl_common_debug.lib")
#pragma comment(lib, "pcl_features_debug.lib")
#pragma comment(lib, "pcl_filters_debug.lib")
#pragma comment(lib, "pcl_io_debug.lib")
#pragma comment(lib, "pcl_io_ply_debug.lib")
#pragma comment(lib, "pcl_kdtree_debug.lib")
#pragma comment(lib, "pcl_keypoints_debug.lib")
#pragma comment(lib, "pcl_octree_debug.lib")
#pragma comment(lib, "pcl_registration_debug.lib")
#pragma comment(lib, "pcl_sample_consensus_debug.lib")
#pragma comment(lib, "pcl_search_debug.lib")
#pragma comment(lib, "pcl_segmentation_debug.lib")
#pragma comment(lib, "pcl_surface_debug.lib")
#pragma comment(lib, "pcl_tracking_debug.lib")
#pragma comment(lib, "pcl_visualization_debug.lib")

** I don't need above all things but I don't know, what they do................

7. Types sample codes

#include <pcl/visualization/cloud_viewer.h>
#include <iostream>
#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>


int main ()
{
 pcl::PointCloud<pcl::PointXYZ> cloud;
 cloud.width    = 10000;
 cloud.height   = 1;
 cloud.is_dense = false;
 cloud.points.resize (cloud.width * cloud.height);
 for (size_t i = 0; i < cloud.points.size (); ++i)
 {
  cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
  cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
  cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
 }
 for (size_t i = 0; i < cloud.points.size (); ++i)
  std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

 pcl::visualization::CloudViewer viewer("PCL Viewer");
 viewer.showCloud(cloud.makeShared());
 while (!viewer.wasStopped());
 return 0;
}


<results>





2016년 2월 14일 일요일

[C++]MFC, Release method including static library

When you release your project without static library, the released exe. file would not work on other PC. That is because libraries related to your project are not included in your released file. Here I will introduce the release method including static library to prevent the happening described above.

1) In your project properties, set configuration from debug to release.
2) Click the General tab of configuration properties, 
3) Change 'Use MFC in a shared DLL' to 'Use MFC in a static library'
4) Nextly, move the Code generation tab of C/C++
5) Change '/MD' to '/MT' in the runtime library.

details are shown in below figure.





2016년 2월 12일 금요일

[C++]MFC, obtain the pointer of MainFrame, Doc, View classes

MFC, obtain the pointer of MainFrame, Doc, View classes 


// Notice: Before doing below, you have to include the header of the pointer to be obtained.



※ CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd();

1. MainFrame Pointer
CMainFrame *frame = (CMainFrame*)AfxGetMainWnd();

2. Doc class Pointer
CxxxDoc *pDoc = (CxxxDoc*)(frame->GetActivedocument());

3. View class Pointer
CxxxView* pView = (CxxxView*)((CMainFrame*)(AfxGetApp()->m_pMainWnd))->GetActiveView();

--------------------------------------------------------------------------
[SDI Type]

1. MainFrame pointer
- CMainFrame *pFrame = (CmainFrame *) AfxGetMainWnd();

2. App class pointer
- CTestApp *pApp = (CtestApp *) AfxGetApp();

3. Document class pointer
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
  CTestDoc *pDoc = (CTestDoc *)pFrame->GetActiveDocument();
- CTestDoc *pDoc = ((CMainFrame *)AfxGetMainWnd())->GetActiveDocument();

4. View class pointer
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
  CTestView *pView = (CTestView *)pFrame->GetActiveView();
- CTestView *pView = ((CMainFrame *)AfxGetMainWnd())->GetActiveView();
 --------------------------------------------------------------------------------
[MDI type]

1. ChildFrame pointer
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
  CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
- CChildFrame *pChild = ((CMainFrame *)AfxGetMainWnd())->GetActiveFrame();

2. Document pointer
- CMainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
  CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
  CMdiTestDoc *pDoc = (CMdiTestDoc *)pChild->GetActiveDocument();
- CMdiTestDoc *pDoc = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveDocument();

3. View pointer

- CCainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
  CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
  CMdiTestView *pView = (CMdiTestDoc *)pChild->GetActiveView();
- CMdiTestView *pView = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveView();


** This post is written by courtesy of http://egloos.zum.com/printf/v/1940633

2016년 2월 1일 월요일

[C++] MFC, Add dialog to a SDI based project

Summary to add dialog (formview) to a project based on SDI.

1. Firstly, Create a new project which is based on SDI.

2. Add a new dialog to resource.

3. Add class to the added dialog (should be based on CDialog class) (ex. CMyDlg)

4. Add a member function "BOOL Create(Cwnd* pParentWnd); " in CMyDlg class.

5. type below codes for the member function in .cpp file of the above class,

BOOL CMyDlg::Create(CWnd* pParentWnd)
{
           return CDialog::Create(IDD, pParentWnd);
}

6. include "CMyDlg" in main frame class (Or View class)

7. declare the added class' instance (e.g., CMyDlg *dlg;)

8. Lastly, in .cpp file of Main frame class (or view class), type below codes in OnCreate (if there is no OnCreate, add message function) ,
     dlg = new CMyDlg;
       dlg->Create(this);
       dlg->ShowWindow(SW_SHOW);
       dlg->MoveWindow(0,0,1024,64); 



Additionally, if menu buttons (or event handler) are used for create the dialog, 
refer to below functions:

bool CMFC_TESTView::CreateChildDlg(void)
{
        if(dlg != NULL) return 0;
               dlg = new CMyDlg;
       
               if(dlg->GetSafeHwnd() ==0)
               {
                       if(!dlg->Create(this)) return 0;
                       else {dlg->ShowWindow(SW_SHOW);
        //dlg->MoveWindow(0,0,1024,64);
                              }
               }

  
        return TRUE;
}


bool CMFC_TESTView::DestroyChildDlg(void)
{
               if(dlg != NULL)
                       if(!dlg->DestroyWindow()) return FALSE;
       
        dlg =NULL;
        return TRUE;
}



2012년 8월 12일 일요일

Opening image/avi/webcam on MFC dialog window using OpenCV2.3

In the previous post, I opened image/avi/webcam on console window with OpenCV library. Sometimes, console window could be inconvenient for user, because it bases on DOS command. MFC that is a kind of object-based programming tool provides class libraries for  development of window application program. Understanding MFC is not easy for developer, but  for user, it provide good UI(user interface).
Consequently, studying MFC deserve it..
From now on, I will study both MFC and Window API programming with OpenCV2.3.
Anyway this post is about opening image/avi/webcam on MFC dialog window.


Before start, run the Visual studio2008 and make new project. Select MFC Application and dialog based like images shown below.



What a weird configuration!
Don't be confused. 

First, let's set up OpenCV library on it.

And include cv.h and highgui.h in C****Dlg.h

Second, go to resource view and make picture controls and buttons like below.

Add each picture control to variable and name its ID.




Now, a function is needed for convert image to bitmap because MFC support only bmp files. Until OpenCV 2.2, a class named CvvImage is provided and that class provides useful function for using image file in MFC, but from ver2.3, CvvImage class is not provided. So, Some functions that can change any image to bitmap file is needed. 


It is a little bit hard opening image on MFC without CvvImage, but fortunately I found a function in OpenCV Korea cafe.

The function is as follows:
 -------------------------------------------------------------------------------------
void DisplayIplImg(IplImage* pImgIpl, CDC* pDC, CRect rect)
{
 BITMAPINFO bitmapInfo;
 bitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
 bitmapInfo.bmiHeader.biPlanes=1;
 bitmapInfo.bmiHeader.biCompression=BI_RGB;
 bitmapInfo.bmiHeader.biXPelsPerMeter=100;
 bitmapInfo.bmiHeader.biYPelsPerMeter=100;
 bitmapInfo.bmiHeader.biClrUsed=0;
 bitmapInfo.bmiHeader.biClrImportant=0;
 bitmapInfo.bmiHeader.biSizeImage=0;
 bitmapInfo.bmiHeader.biWidth=pImgIpl->width;
 bitmapInfo.bmiHeader.biHeight=-pImgIpl->height;
 IplImage* tempImage;
 if(pImgIpl->nChannels == 3)
 {
  tempImage = (IplImage*)cvClone(pImgIpl);
  bitmapInfo.bmiHeader.biBitCount=tempImage->depth * tempImage->nChannels;
 }
 else if(pImgIpl->nChannels == 1)
 {
  tempImage =  cvCreateImage(cvGetSize(pImgIpl), IPL_DEPTH_8U, 3);
  cvCvtColor(pImgIpl, tempImage, CV_GRAY2BGR);
  bitmapInfo.bmiHeader.biBitCount=tempImage->depth * tempImage->nChannels;
 }
 pDC->SetStretchBltMode(COLORONCOLOR);
 ::StretchDIBits(pDC->GetSafeHdc(), rect.left, rect.top, rect.right, rect.bottom,
  0, 0, tempImage->width, tempImage->height, tempImage->imageData, &bitmapInfo,
  DIB_RGB_COLORS, SRCCOPY);
 cvReleaseImage(&tempImage);
}
--------------------------------------------------------------------------------

Among 3 variables used in the function, pImgIpl means point variable of image loaded by OpenCV,  pDC means structure information where to open image, and rect means size of where to open image. pDC and rect should be declared by CDC class and CRect class variables before using. 
  
Let's declare variables.



IplImage* image;
CDC* pDC1;
CRect rect1;
These variables are for load image on picture control. 
And then go to OnInitDialog function that is pre-process as soon as run this project.
Type like below.

--------------------------------------------------------
 image = cvLoadImage( "test.jpg" );
 pDC1 = m_pic.GetDC();
 m_pic.GetClientRect(&rect1);
---------------------------------------------------------



Now, add function to display image.



Name of Function is DisplayIplImg, and input each parameter on it
-----------------------------------------------------------------------
void DisplayIplImg(IplImage* pImgIpl, CDC* pDC, CRect rect)


--------------------------------------------------------------

And then go to where the function is declared, copy and paste codes of function


Third, move on to dialog window and double click Load Image button. In there you can make some event.Input below codes in the event function.

-------------------------------------------------------------------
DisplayIplImg(image, pDC1,rect1);
--------------------------------------------------------------------




Move on to dialog window againg and double click close button. In there, input below codes.
-----------------------------------------------------------------------
cvReleaseImage(&image);
-----------------------------------------------------------------------




Now, Let's code for the video clip and webcam to open on dialog window. Both of two are similar. outline is as follows:

1) Declare variables

2) Get the information of picture control
    start capture from video and save buffer for moment

3) Set the timer and call and display buffer image when timer on





1. Declare variables
use Add->Variables  on c***Dlg class and input below
------------------------------------
IplImage* m_FrameVideo;
IplImage* m_FrameWebcam;
CvCapture* captureAVI;
CvCapture* captureCAM;
CDC* pDC2;
CDC* pDC3;
CRect rect2;
CRect rect3;
-------------------------------------

2. Go to initializing function of the class. You can see it easily as double clicking on C***Dlg class. It is same place where you input codes for opening image.

---------------------------------------------------------------------

captureAVI = cvCreateFileCapture( "test.avi" );
captureCAM = cvCaptureFromCAM(0);

pDC2 = m_video.GetDC();
m_video.GetClientRect(&rect2);
pDC3 = m_cam.GetDC();
m_cam.GetClientRect(&rect3);
----------------------------------------------------------------------------



3. In dialog window, just double clink on Open VideoClip button. Then input below codes.
    Repeat again on WebCAM button.

-------------------------------------------------------------
//(In Open VideoClip button)
SetTimer(1,30,NULL);
---------------------------------------------------------------
//(In Open WebCAM button)
SetTimer(2,30,NULL);
-----------------------------------------------------------

In SetTimer Function, first parameter means channel of timer, second parameter means how frequent call Ontimer function.



Go to Message Handler and make OnTimer()



  ------------------------------------------------------------------------
//in OnTimer()

        if(nIDEvent == 1)
        {
              
               m_FrameVideo = cvQueryFrame( captureAVI );
               if(!m_FrameVideo) KillTimer(1);
               else DisplayIplImg(m_FrameVideo, pDC2, rect2);
        }
        if(nIDEvent ==2)
        {
               m_FrameWebcam = cvQueryFrame( captureCAM );
               DisplayIplImg(m_FrameWebcam, pDC3, rect3);
        }


----------------------------------------------------------------




Finally, go to close button function and release memory.
--------------------------------------------------------
cvReleaseCapture(&captureAVI);
cvReleaseCapture(&captureCAM);

------------------------------------------------------------



Result