我想在VC程序中获取USB口的摄像头数据,请问那位高手知不知道有没有什么API函数之类的啊!多谢了各位,如果有源代码更好!

解决方案 »

  1.   

    什么数据?有些属性值可以用DeviceIoControl()从流类的驱动中读。see msdn,
      KSPROPERTY, ...
      

  2.   

    使用vfw          char achDeviceVersion[80] ; // 设备版本信息
              char achDeviceAndVersion[160]; //设备名及版本信息
              int uIndex;
      DriverCount=0;//支持的设备驱动程序个数
           for(uIndex=0;uIndex<5;uIndex++)
       {
       if(capGetDriverDescription(uIndex,(LPSTR)achDeviceAndVersion,sizeof(achDeviceAndVersion),(LPSTR)achDeviceVersion,sizeof(achDeviceVersion)))
       {
       strcat(achDeviceAndVersion,",");
               strcat(achDeviceAndVersion,achDeviceVersion);
               DriverCount++;    }
       else
       break;
       }    if(DriverCount==0)
       MessageBox("找不到视频设备,请确认已正确连接","错误信息",MB_ICONSTOP|MB_OK);
           else
       {
             
       CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
           CTest11View *pView=(CTest11View *)pFrame->GetActiveView();
       HWND hWnd;
       hWnd=pView->GetSafeHwnd();
     
    RECT rc;
    GetClientRect(&rc);
            hWndCap=capCreateCaptureWindow(NULL,
    WS_CHILD|WS_VISIBLE,30,70,
    (rc.right-rc.left)/4,(rc.bottom-rc.top)/4,
    hWnd,//parent window
    0          //chile window id
    );//建立视频采集窗口
    ASSERT(hWndCap);
    if(capDriverConnect(hWndCap,--uIndex))//判断采集窗口是否与0号采集卡驱动相连接 {
    //获取视频设备采集能力
    capDriverGetCaps(hWnd,&CapDriverCaps,sizeof(CAPDRIVERCAPS));
            if(CapDriverCaps.fCaptureInitialized)//初始化成功

    {  // 设置Preview模式的频帧
                capPreviewRate(hWndCap, 20); 
                //启动Preview模式
                capPreview(hWndCap, TRUE);
        //设置每帧结束后所调用的回调函数
    //capSetCallbackOnFrame(hWndCap,FrameCallbackProc);
     
     //如果支持视频源选择,则弹出视频源选择对话框
    if(CapDriverCaps.fHasDlgVideoSource)
     capDlgVideoSource(hWnd);
    //如果支持视频格式选择,则弹出视频格式选择对话框
            if(CapDriverCaps.fHasDlgVideoFormat)
    capDlgVideoFormat(hWnd);
    //如果支持视频显示格式选择,则弹出视频显示格式选择对话框
            if(CapDriverCaps.fHasDlgVideoDisplay)
    capDlgVideoDisplay(hWnd);
    }
    else//初始化不成功
       MessageBox("捕获卡初始化失败","错误信息",MB_ICONSTOP|MB_OK);
       }
    else
               MessageBox("捕获卡连接失败","错误信息",MB_ICONSTOP|MB_OK);
       }
      

  3.   

    # include <vfw.h>//加入视频采集所需头文件
      

  4.   

    多谢楼上的指教,使我明白了很多,真的是要谢谢楼上各位。现在我想做关于摄像头的东东,不知道各位知道网上哪儿有比较好的资料没有,毕竟小弟english.....或则是什么好的书籍。如怎么得到摄像头的视频数据啊,以及用什么方式显示最好啊等等。如果各位知道多少也可以在这多指点指点,我很感激不尽。
      

  5.   

    我想请问zhiheng(好好学习 天天向上)你的程序应该是使用在那的?是在对话框中么?
    为什么我把他放到View中有连接错误啊?
    est11View.obj : error LNK2001: unresolved external symbol _capCreateCaptureWindowA@32
    Test11View.obj : error LNK2001: unresolved external symbol _capGetDriverDescriptionA@20
    Debug/Test11.exe : fatal error LNK1120: 2 unresolved externals
      

  6.   

    视频捕捉有两种方法,vfw或者wdm不过现在有更好的方法就是directshow
      

  7.   

    需要用到Vfw32.lib库,在project->setting->link->object/library modules中添加
      

  8.   

    太感激zhiheng(好好学习 天天向上)了,我简直不知道该用什么表达我的心情:)
      

  9.   

    还想多问一句,可能我也实在是问的比较多真的不好意思:(
    lpVHdr->lpData的数据格式是什么?就是图片信息么?没有编码?有是用什么编码啊,格式是什么,是不是与摄像头设备或驱动有关啊。
      

  10.   

    这一部分我也没有深入的研究
    我估计是每一帧图片的信息
    它的格式应该和你捕获的单帧图像一样
    it‘s just my opinion!
      

  11.   

    DESIGN AND DEVELOPMENT OF A PROTOTYPE COMMERCIAL VEHICLE OPERATOR INFORMATION SYSTEM
    By
    T.H. Maze, Director
    Christopher Albrecht, Research Assistant
    Marilyn Kuntemeyer, Senior Project Manager
    Center for Transportation Research and Education
    Iowa State University
    SUMMARY
    This paper discusses the development of a prototype commercial vehicle operator information system. The system was developed for the Des Moines, Iowa metropolitan area, but the design is transferable to other locations. The paper describes the differences in data requirements for a commercial vehicle operator system and a non-commercial traveler system, as well as the information elements included in and the design of a non-commercial traveler system. 
    INTRODUCTION
    In 1995, groups of state regulator and enforcement officials, motor carrier representatives, state transportation department personnel, motor carrier representatives, and ITS service and technology providers gathered in Des Moines, Iowa and formed a focus group to identify priorities for the deployment of ITS for Commercial Vehicle Operations (CVO) in the midwest. The group also investigated issues related to motivating cooperation between states in the deployment of the systems identified. Because most over-the-road truck service is interstate, to achieve significant benefits, ITS-CVO applications must cross state borders; hence, the importance of cooperation between states. 
    Most of the ITS-CVO functions identified by the focus group were consistent or the same as one of the user services identified in the U.S. national program plan with one exception. The exception was the development of commercial vehicle operator (usually truck operators) information systems. Although substantial research and development has been given to urban traveler information systems and a significant amount of work has been conducted on rural traveler and tourism information systems, little has been found which specifically focuses on the needs of commercial vehicle operators. 
    The information needs of commercial vehicle operators are often quite different in content or are different in the spatial dimensions of the information compared to the needs of ordinary travelers. Content differences relate to information that is important to commercial vehicle operators, like the locations where spaces are available to park a trailer for the night or height restrictions on bridge underpasses. Differences in the spatial content relates to the long distances covered by commercial travelers. For example, both truck operators and urban commuters are interested in present and future road conditions due to changing winter weather. The difference between the two types of travelers is that at noon a commuter may be interested in the expected road conditions for the trip home from work at 5:00 p.m., while at noon the commercial vehicle operator may be interested in the road conditions at a location 450 kilometers away at 5:00 p.m. The focus group identified a commercial traveler information system as a high priority for deployment and one that faces few, if any, institutional issues.
    As part of a project focusing the planning of ITS functions for the Des Moines metropolitan area (an Early Deployment Plan), the content for a commercial vehicle operator information system was researched, and a working prototype was developed. Since some of the information requirements identified were not supportable using existing data sources, the prototype system did not accommodate all of the information requirements. The system focused only on Des Moines and central Iowa, however, there is nothing unique to Des Moines that would not allow the system designed to be transferred to other locations. Further, the benefits of a commercial vehicle operator information system are likely to be more substantial for larger urban areas than for medium-sized urban areas like Des Moines.
      

  12.   

    Commercial vehcicle operator Information System Prototype Development
    To guide the researchers in the identification of the information which should be contained in the system, several steps were followed. First, the focus group that met in 1995 provided some direction regarding the desired information contained in a commercial traveler system. They focused on three types of information. The first type of information involved identifying locations where trucks may be parked overnight and the driver amenities and security associated with these sites. The growth in long-distance truck traffic has resulted in an escalating demand for parking locations where drivers may rest. The American Truck Associations has estimated that there is a national shortage of truck parking locations and that 28,000 spaces are needed at public rest areas.(1) The second type of information related to long- distance roadway conditions and weather conditions. This would require access to a national database or at least a regional database of road construction, road closures, and current and forecast roadway weather conditions. The third type of information covered physical or regulatory restrictions on the use of highway facilities by trucks. This included height restrictions on bridge underpasses, weight restrictions on roadways or bridges, and regulatory restrictions on the use of highways by trucks. Cities with a significant number of height-restricted bridge underpasses or changes in the height restrictions due to roadway maintenance (e.g., pavement overlays) can present significant challenges to over-the-road truck operators attempting to make a delivery or pickup.
    The next step in defining the functions for the information system was to interview the operators of truck service centers (truck stops) to determine the types of information they are commonly asked for by truck operators and the type of information they would like to see made available to truck operators. The information needs defined through these interviews related to identifying and describing the service attributes of personal service providers (e.g., walk-in dental services, walk-in medical care services, etc.), equipment services, and driver amenities and electronic commerce facilities (e.g., electronic load matching, automatic teller machines, FAX-based permit purchasing, etc.) provided by truck service center operators. 
    The last step was to review the information elements already identified with truck company managers and operators. In general, these discussions identified additional truck operator amenities to be included (e.g., restaurants and motels located near interstate highway interchanges), additional personal services, and refinement of the description of services.
    Information System Content and Design
    The prototype system was developed to provide information over the World Wide Web and, hence, to provide widespread access to the information and to allow users access information through a graphical user interface which includes clickable maps defining the locations of services and facilities. Eventually, access to a working system could be provided at public facilities (rest stops) through kiosks, with access limited to only a defined set of addresses and through computers connected to the internet at truck service centers, truck terminals, and other commercial facilities. At present, some truck-related commerce is already appearing on the World Wide Web, such as load matching and truck brokerage services, and ,therefore, truck service centers are likely to provide access to Web browsers similar to the other communication services typically provided today.
    Below are listed the elements included in the prototype system or recommended for future operational systems.
    General Services
    Weather - Current weather conditions and forecast weather conditions. In the prototype this will be provided through a link to a weather information service page.
    Roadway Weather Conditions - A World Wide Web page is currently under construction by the Iowa Department of Public Safety, which identifies the current roadway conditions along the major highways in the state. The prototype commercial traveler information system will link to this road condition page. However, in the near future, the Iowa Department of Transportation and other departments of transportation in the region will have roadway weather information systems. When information from these systems is available, it will be possible to display better, more comprehensive, and more current information.
    Rest Stops - Rest stop locations along the interstate in the metropolitan area will be shown on a map. A layer beneath the map will contain services available at each rest stop (i.e., number of parking spaces for trucks, cars, cars with trailers; the presence of vending machines; and other facilities).
    Restricted Access Location - Locations on public highways in the Des Moines metropolitan area, where access by trucks is restricted by local ordinances or by restricted height on bridges, are shown on a road map, with a layer beneath the map describing the restriction.
    Traffic Congestion and Travel Time Information in Urban Areas Within the Region - Currently, real time information is not available for Des Moines and for many of the urban areas in the region and, therefore, the prototype does not include any information on traffic congestion or current travel time information. At some point in the future, real time information will be available for Des Moines. At that point, the system should include real-time data or a link to a map displaying real-time data. For other major metropolitan areas, average speeds on the urban area's major highways by time of day and day of the week would be of more value than current conditions. Thus, when an actual system is deployed, historical data on average travel speeds for urban areas other than Des Moines may be all that is needed.
      

  13.   

    Commercial Vehicle Operator Business Locations
    Iowa Department of Transportation's Truck Service Center - A map shows the location of the Iowa Department of Transportation's truck service center in Des Moines. The layer beneath the map lists the services provided at the Iowa Department of Transportation service center and its hours of operation.
    Permit Services - A map shows the location of permitting services throughout the metropolitan area, as well as permit services co-located with the truck service center. The layer beneath the map identifies the services provided.
    Iowa Motor Truck Association - The location of the Iowa Motor Truck Association is shown on a map. The layer beneath the map will identify the services available from the Iowa Motor Truck Association.
    Load Services - The location of truck brokers and access points for electronic load services is shown on a map. The layer beneath the map will list the services provided at each location.
    Postal and Package Delivery Services - The location of post offices near the interstate, and drop-off boxes for package delivery services near interstate interchanges is shown on a map.
    Domestic and International Electronic Credentialling - Current ITS Operational Tests are demonstrating the ability to procure domestic credentials electronically. The Operational Test uses dial-up modem accesses. In the future, these functions will migrate to the World Wide Web and, at that point in time, access should be provided through the commercial traveler information system. In field tests of the North American Trade Automation Protocol (NATAP), the ability to file an international movement shipment with federal authorities is being tested. Submission of data to NATAP is already being conducted through the World Wide Web. In the future, access to NATAP can also be provided through the commercial traveler information system.
    Personal Service Locations
    Walk-in Dental Services - The location of walk-in dental offices is shown on a map. The layer beneath the map contains information on the office, as well as any special services provided by the dental office.
    Walk-in Medical Services - The location of walk-in medical offices is shown on a map. The layer beneath the map contains information on the office, as well as any special services provided by the medical office.
    Entertainment - The page will predominately carry referrals to information services (e.g., movie hotline) and will link to the Web site of the Des Moines Convention and Visitors Bureau.
    Restaurants - The location on a map of all restaurants listed on Iowa Department of Transportation information signs along the interstate. Also indicated in the restaurant's description is whether or not there is truck parking available. 
    Truck Service Centers and Equipment Services
    Truck Service Centers - A map contains the logos of various truck service centers (truck stops) at locations in and around the metropolitan area. The layer beneath the map contains a list of services. This will include driver amenities offered (e.g., secure parking facility, showers, church services, etc.) and electronic commerce services offered (ATM machines, fuel cards, cable TV access, electronic load postings, and internet access).
    Engine Dealers - The location of diesel engine dealers is displayed on a clickable map. The layer beneath the map includes information on the engine dealer and the services offered.
    Truck Dealerships - The location of truck dealerships is displayed on a clickable map, and the layer beneath contains the services offered by the dealership.
    Refrigeration Repair Facilities - The location of truck dealership is displayed on a clickable map, and the layer beneath the map will identify the services offered.
    Tire Dealers - The location of truck dealerships is displayed on a clickable map and the layer beneath will identify the services offered.
    Truck Towing Services - The location of truck towing services is displayed on clickable map, and the layer beneath will identify the services offered.
    Conclusion
    Traveler information systems for commercial travelers is different in content and presentation from the system designed for non-commercial travelers. The prototype commercial traveler information system is intended to demonstrate commercial traveler stakeholders (e.g,, trucking firms, the regional transportation planning agency, and the state and U.S. departments of transportation) the value of packaging information which focuses on the needs of commercial travelers. Regional stakeholders will be given access to the prototype system through the Iowa Motor Truck Association's World Wide Web page to evaluate the utility of the system.
    REFERENCES
    1. Thomas M. Strah, "Drivers Need More Room to Rest," Transport Topics, May 20, 1996.
      

  14.   

    to:qiufang518(邱芳)
    不知道你说的是什么东东啊,全都是英文的,好象和我问的没有什么关系啊!
    不知道是不是我的英语水平有限,还希望你能指点。
      

  15.   

    从微软网站下载一个DX9SDK,在其中的DIRECTSHOW编程中有这样类似的例子代码