目前分類:未分類文章 (7)

瀏覽方式: 標題列表 簡短摘要

1. FreeMediaType()

ERROR: strmbasd.lib(wxdebug.obj) : error LNK2019: unresolved external symbol __imp__timeGetTime@...........

SOL: #pragma comment(lib,"winmm.lib")

 

2. _WIN32_WINNT

ERROR: VS2010 Build Error:fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x0403..

SOL:

(A) Add these code at stdafx.h

#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0501 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0601 // Change this to the appropriate value to target IE 5.0 or later.
#endif

 

(B) Properties->Configuration Propoerties->C/C++->Preprocessor->Preprocessor Definitions

Add _WIN32_WINNT=0x6000


Refer to:

http://connect.microsoft.com/VisualStudio/feedback/details/564673/problem-with-win32-winnt

http://tw.myblog.yahoo.com/josh-chang/article?mid=1436

http://blog.csdn.net/liuxg2008/article/details/6544961

文章標籤

trick 發表在 痞客邦 留言(0) 人氣()

1. Download and install Visual Studio 2010 express (free) on your PC.


2. Download and install Microsoft DirectX 9.0 SDK Update (Summer 2004)

    which contains DirectShow

    P.S. After DirectX 9.0b, DirectShow has been moved to Windows Platform SDK.

    P.S. Other DirectX versions which include DirectShow are also suitable.

    P.S. In this article, DirectX was installed in C:\Program Files\DirectX


3.To get strmbasd.lib (in DEBUG & RELEASE modes),

   build baseclasses.sln in ./Samples/C++/DirectShow/BaseClasses 

   You may encounter many errors during this step:


   3.1 ctlutil.h:

      "operator=(LONG);" to "COARefTime& operator=(LONG);"

   3.2 wxdebug.cpp:

      "static g_dwLastRefresh = 0;" to "static int g_dwLastRefresh = 0;"

   3.3 winutil.cpp:

      "for (Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) {"

        to "for (int Count = PalLoCount;INT(Count) < min(PalHiStart,iColours);Count++) {"

   3.4 outputq.cpp

       Add the line long iDone = 0; just before the 

       "for (iDone = 0;iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway);"

   3.5 Errors at 

       "typedef void *PVOID;  typedef void *POINTER_64 PVOID64;"

       Add "#define POINTER_64 __ptr64" before them

   3.6 Others:

      Google them or Refer to 

      http://blog.csdn.net/yuanbingster/article/details/5573141

      http://blog.csdn.net/Amy_1007/article/details/5574607

      http://blog.xuite.net/miinyuan/blog/23556251


4. New a Project for DirectShow

   

   4.1 Set Project->Properties->Configuration Properties->VC++ Directories->Include Directories

      C:/Program Files/DirectX/Samples/C++/DirectShow/BaseClasses

      C:/Program Files/DirectX/Include

   4.2 Set Project->Properties->Configuration Properties->VC++ Directories->Library Directories

      C:/Program Files/DirectX/Samples/C++/DirectShow/BaseClasses/Debug

      C:/Program Files/DirectX/Samples/C++/DirectShow/BaseClasses/Release

      C:/Program Files/DirectX/Lib

   4.3 Include header files

      #include <dshow.h> // for all DirectShow applications

      #include <streams.h> // for DirectShow Base Class

   4.4 Import library

      (a) Add #pragma comment(lib,"strmbasd.lib") in header file

      (b) Set Project->Properties->Configuration Properties->Linker->Command Line

            ->Additional Options: strmbasd.lib

   4.5 Notes

      (a) error in wxdebug.h: Add #include <tchar.h> and #define PTCHAR (TCHAR *) 

      (b) Error C1189: #error : Include <strsafe.h> after <tchar.h>,

           add #include <tchar.h> ahead of other header files

      (C) Failed to save the updated manifest to the file: Delete the Debug folder

           Ex: If you change (install, modify, unistall) the codec intsalled on the computer,

                 you may face this problem.


5. Sample Code for Playing a Video 

#include <dshow.h>
#include <streams.h>
#include <stdio.h>

#pragma comment(lib,"strmbasd.lib") // see 4.4 Import library

#define FILENAME L"D:\\TEST.avi"

void main()
{
      IGraphBuilder *pGraphBuilder = NULL;
      IMediaControl *pMediaControl = NULL;
      IMediaEvent *pMediaEvent = NULL;

      // Initialize the COM library.
      HRESULT hr = CoInitialize(NULL);
      if (FAILED(hr)){
          printf("ERROR - Could not initialize COM library");
          return;
      }

     // Create the filter graph manager and query for interfaces.
     hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC,
          IID_IGraphBuilder, (LPVOID *)&pGraphBuilder);

     if (FAILED(hr)){
          printf("ERROR - Could not create the Filter Graph Manager.");
          return;
     }

     hr = pGraphBuilder->QueryInterface(IID_IMediaControl, (LPVOID *)&pMediaControl);
     hr = pGraphBuilder->QueryInterface(IID_IMediaEvent, (void **)&pMediaEvent);

     // Build the graph.
     hr = pMediaControl->RenderFile(FILENAME);
     if (SUCCEEDED(hr))
     {
          // Run the graph.
          hr = pMediaControl->Run();
          if (SUCCEEDED(hr))
          {
               // Wait for completion.
               long evCode;
               pMediaEvent->WaitForCompletion(INFINITE, &evCode);

 

              // Note: Do not use INFINITE in a real application, because it
              // can block indefinitely.
          }
     }

     pMediaControl->Release();
     pMediaEvent->Release();
     pGraphBuilder->Release();
     CoUninitialize();
}


6. DirectShow Programming: 

    http://www.geekpage.jp/en/programming/directshow/

文章標籤

trick 發表在 痞客邦 留言(0) 人氣()

int cvKMeans2(const CvArr* samples, int nclusters, CvArr* labels, CvTermCriteria termcrit, int attempts=1, CvRNG* rng=0, int flags=0, CvArr* centers=0, double* compactness=0)


Parameters:

  • samples – Floating-point matrix of input samples, one row per sample
  • nclusters – Number of clusters to split the set by
  • labels – Output integer vector storing cluster indices for every sample
  • termcrit – Specifies maximum number of iterations and/or accuracy (distance the centers can move by between subsequent iterations)
  • attempts – How many times the algorithm is executed using different initial labelings. The algorithm returns labels that yield the best compactness (see the last function parameter)
  • rng – Optional external random number generator; can be used to fully control the function behaviour
  • flags – Can be 0 or CV_KMEANS_USE_INITIAL_LABELS. The latter value means that during the first (and possibly the only) attempt, the function uses the user-supplied labels as the initial approximation instead of generating random labels. For the second and further attempts, the function will use randomly generated labels in any case
  • centers – The optional output array of the cluster centers
  • compactness – The optional output parameter, which is computed as after every attempt; the best (minimum) value is chosen and the corresponding labels are returned by the function. Basically, the user can use only the core of the function, set the number of attempts to 1, initialize labels each time using a custom algorithm (flags=CV_KMEAN_USE_INITIAL_LABELS) and, based on the output compactness or any other criteria, choose the best clustering.

 

The function cvKMeans2() implements a k-means algorithm that finds the centers of nclusters clusters and groups the input samples around the clusters. On output, contains a cluster index for samples stored in the i-th row of the samples matrix.

文章標籤

trick 發表在 痞客邦 留言(0) 人氣()

(1) Download OpenCV2.2 from Source Forge

Download the OpenCV-2.2.0-win32-vs2010.exe 

as it already contains the libraries and the binaries required for running OpenCV.

You can untar the file into a directory named /opencv2.2/

(直接下載OpenCV-2.2.0-win32-vs2010.exe,就不用在自己編譯OpenCV2.2)

 

(2) Download and install Visual Studio 2010 express (free) on your PC.

 

(3) Once Visual Studio 2010  is installed open VC++ and select  “New Project” and choose Win32 Console Application for e.g. OpenCVTest

 

(4) Include the any relevant OpenCV code into main.cpp

#include <cv.h>
#include <cxcore.h>
#include <highgui.h>


int main(int argc, char* argv[])
{
        IplImage *img = cvLoadImage("test.jpg");
        cvNamedWindow("Image:",1);
        cvShowImage("Image:",img);


        cvWaitKey();
        cvDestroyWindow("Image:");
        cvReleaseImage(&img);
        
        return 0;
}

 

(5) Include the following 3 directories under

Project->OpenCVTest properties->VC++ Directories->Include Directories. Click Edit

.\opencv2.2\include

.\opencv2.2\include\opencv

.\opencv2.2\include\opencv2

Click Apply and OK

 

(6) Now include the library path

Project->OpenCVTest properties->Library Directories

.\opencv2.2\lib

Click Apply and OK

 

(7) Now the last step is to include all the necessary OpenCV libraries during the linking phase

For this go to Project->OpenCVTest properties->Linker->Input->Additional Dependencies and cut and paste all the following libraries by clicking the “Edit”

opencv_calib3d220.lib
opencv_calib3d220d.lib
opencv_contrib220.lib
opencv_contrib220d.lib
opencv_core220.lib
opencv_core220d.lib
opencv_features2d220.lib
opencv_features2d220d.lib
opencv_ffmpeg220.lib
opencv_ffmpeg220d.lib
opencv_flann220.lib
opencv_flann220d.lib
opencv_gpu220.lib
opencv_gpu220d.lib
opencv_highgui220.lib
opencv_highgui220d.lib
opencv_imgproc220.lib
opencv_imgproc220d.lib
opencv_legacy220.lib
opencv_legacy220d.lib
opencv_ml220.lib
opencv_ml220d.lib
opencv_objdetect220.lib
opencv_objdetect220d.lib
opencv_ts220.lib
opencv_video220.lib
opencv_video220d.lib

 

Click Apply and Ok.

 

(8) Fix the bugs in ffmpeg (for reading videos such as *.mpg) [2]  (Optional)


(a) Download the OpenCV-2.2.0-win.zip

(b) Install CMake and build the VS2010 version Solution of OpenCV-2.2.0 [3]

(c) In Release Mode, click right on opencv_ffmpeg project and select  Properties 

(d) Linker-> Debugging->Generate Debug Info->YES (/DEBUG)-> Apply and OK

(e) Click right on opencv_ffmpeg project and build this project (Build)

(f) Copy the release version of opencv_ffmpeg220.dll (OpenCV-2.2.0\build\bin\Release) to override the original opencv_ffmpeg220.dll (OpenCV2.2\bin)




Reffered to

[1] http://gigadom.wordpress.com/2011/11/01/installing-and-using-opencv-with-visual-studio-2010-express/

[2] http://stackoverflow.com/questions/3889373/opencv-crashes-trying-to-read-a-video-with-release-build

[3] http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010_CMake



文章標籤

trick 發表在 痞客邦 留言(0) 人氣()

第一步:下載檔案

1.   下載jdk與tomcat


第二步:安裝JDK

2-1. 先安裝jdk,然後在我的電腦->內容->進階->環境變數->系統變數中,

新增以下環境變數(假定jdk安裝在C:\Program Files\Java):

JAVA_HOME=C:\Program Files\Java\jdk1.7.0

classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;

path=%JAVA_HOME%\bin

*若原來無相對應的變數,要自己新增


2-2. 接著用一個簡單的java程式來測試jdk是否已安裝成功:

public class Test{

public static void main(String args[]){
System.out.println("This is a test program.");
}
}


第三步:安裝TOMCAT

3-1. 安裝Tomcat後,再新增以下環境變數(假定你的tomcat安裝在C:\tomcat)

TOMCAT_HOME=C:\tomcat

TOMCAT_BASE=C:\tomcat

並修改環境變數中的classpath,把C:\tomcat\lib下的servlet-api.jar和jsp-api.jar追加到classpath中。

修改後的classpath如下:

classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%TOMCAT%\common\lib\servlet-api.jar;%TOMCAT%\common\lib\jsp-api.jar;


3-2. 接著使用 "命令提示字元" 進入C:\tomcat\bin,並輸入 ".\startup.bat" 來啟動tomcat,

在瀏覽器中訪問http://localhost:8080,如果看到tomcat的歡迎頁面說明安裝成功。

 

 

第四步:建立自己的JSP app目錄

4-1.進入C:\tomcat\webapps,可以看到ROOT,examples, tomcat-docs之類Tomcat原有的目錄。

4-2.在webapps目錄下新建一個目錄,起名叫myapp。

4-3.接著在myapp下新建一個目錄WEB-INF,注意,目錄名稱是區分大小寫的。

4-4.WEB-INF下新建一個文件web.xml,內容如下:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>My Web Application</display-name>

<description>

A application for test.

</description>

</web-app>


4-5.在myapp下新建一個測試的jsp頁面,文件名為index.jsp,文件內容如下:

<html><body><center>

Now time is: <%=new java.util.Date()%>

</center></body></html>


4-6.重啟Tomcat

4-7.打開瀏覽器,輸入http://localhost:8080/myapp/index.jsp。看到當前時間的話就代表成功了。

 

 

第五步:建立自己的Servlet

5-1.  用你最熟悉的編輯器新建一個servlet程式,文件名為Test.java,文件內容如下:

 

package test;

import java.io.IOException;

import java.io.PrintWriter;

import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

public class Test extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException {

PrintWriter out=response.getWriter();

out.println("<html><body><h1>This is a servlet test.</h1></body></html>");

out.flush();

}

}

 

5-2.  將Test.java編譯,並產生一個編譯後的servlet文件:Test.class

5-3.  將目錄test\Test.class移至C:\tomcat\webapps\myapp\WEB-INF\classes下,

如果classes目錄不存在,就新建一個。

5-4.  修改webapps\myapp\WEB-INF\web.xml,添加servlet 和 servlet-mapping

編輯後的web.xml如下所示,紅色為新增的內容:

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"

"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<display-name>My Web Application</display-name>

<description>

A application for test.

</description>

<servlet>

<servlet-name>Test</servlet-name>

<display-name>Test</display-name>

<description>A test Servlet</description>

<servlet-class>test.Test</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>Test</servlet-name>

<url-pattern>/Test</url-pattern>

</servlet-mapping>

</web-app>

 

*servlet這段聲明要調用的servlet,而servlet-mapping則是將此servlet"映射"到地址/Test

 

5-5.  重啟動Tomcat,啟動瀏覽器,輸入http://localhost:8080/myapp/Test 

如果看到輸出This is a servlet test.就說明編寫的servlet成功了。

 

注意:修改了web.xml以及新加了class,都要重啟Tomcat

 

第六步:建立自己的Bean:
6-1.  新建一個java程式文件名為TestBean.java文件內容如下:
package test;
public class TestBean{
private String name = null;
public TestBean(String strName_p){
this.name=strName_p;
}
public void setName(String strName_p){
this.name=strName_p;
}
public String getName(){
return this.name;
}
}

6-2.  編譯TestBean.java產生TestBean.class
6-3.  將TestBean.class移至C:\tomcat\webapps\myapp\WEB-INF\classes\test下
6-4.  新建一個TestBean.jsp文件於C:\tomcat\webapps\myapp文件內容為:

<%@ page import="test.TestBean" %>
<html><body><center>
<%
TestBean testBean=new TestBean("This is a test java bean.");
%>
Java bean name is: <%=testBean.getName()%>
</center></body></html>

6-5.  重啟Tomcat啟動瀏覽器輸入http://localhost:8080/myapp/TestBean.jsp 
如果看到輸出Java bean name is: This is a test java bean. 就說明編寫的Bean成功了




第七步:這樣就完成了整個Tomcat下的jsp、servlet和javabean的配置

* 本文件從以下頁面修改而來:
Tomcat+JSP经典配置实例 http://www.webjx.com/htmldata/2005-11-17/1132185684.html
1. 先安裝jdk,再設定環境變數:
JAVA_HOME=C:\Program Files\Java\jdk1.7.0
classpath=.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;
path=%JAVA_HOME%\bin
*若無相對應的變數名稱,要自己新增
2. 接著可以用一個簡單的java程式來測試jdk是否已安裝成功:
public class Test{
public static void main(String args[]){
System.out.println("This is a test program.");
}
}
2.
文章標籤

trick 發表在 痞客邦 留言(0) 人氣()

時間過得真快~
一轉眼 ~ 資訊營就結束了....
感謝各位"神資領域"的伙伴^^
                                                               ------>下回待續 = =...

trick 發表在 痞客邦 留言(0) 人氣()

資訊週的檢討會開了快2個鐘頭半,真是累阿= ="
不過還不錯阿!! ~哈
 
 
#(以上純為實驗而打的~)

trick 發表在 痞客邦 留言(1) 人氣()