Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of uvchost by
uvc.h
00001 #ifndef UVC_H 00002 #define UVC_H 00003 #include "UsbBaseClass.h" 00004 #include "usb_mem.h" 00005 #include "usb_mjpeg.h" 00006 00007 #define CLASS_VIDEO 0x0E 00008 00009 #define SET_CUR 0x01 00010 #define GET_CUR 0x81 00011 #define GET_MIN 0x82 00012 #define GET_MAX 0x83 00013 #define GET_RES 0x84 00014 #define GET_LEN 0x85 00015 #define GET_INFO 0x86 00016 #define GET_DEF 0x87 00017 00018 #define VS_PROBE_CONTROL 0x01 00019 #define VS_COMMIT_CONTROL 0x02 00020 00021 #define PAYLOAD_UNDEF 0 00022 #define PAYLOAD_MJPEG 1 00023 #define PAYLOAD_YUY2 2 00024 00025 class uvc : public UsbBaseClass { 00026 public: 00027 uvc(int cam = 0); 00028 ~uvc(); 00029 int setup(); 00030 int get_jpeg(const char* path); 00031 int get_jpeg(uint8_t* buf, int size); 00032 bool interrupt(); 00033 int isochronous(); 00034 void attach(usb_stream* stream); 00035 void detach(); 00036 ///set format index 00037 void SetFormatIndex(int index = 1); 00038 ///set frame index 00039 void SetFrameIndex(int index = 1); 00040 ///set frame interval 00041 void SetFrameInterval(int val = 2000000); 00042 ///set packet size 00043 void SetPacketSize(int size = 128); 00044 ///set image size 00045 void SetImageSize(int width = 160, int height = 120); 00046 ///set payload MJPEG or YUY2 00047 void SetPayload(int payload); // MJPEG,YUV422(YUY2) 00048 UsbErr Control(int req, int cs, int index, uint8_t* buf, int size); 00049 ///Setups the result callback 00050 /** 00051 @param pMethod : callback function 00052 */ 00053 void setOnResult( void (*pMethod)(uint16_t, uint8_t*, int) ); 00054 00055 ///Setups the result callback 00056 /** 00057 @param pItem : instance of class on which to execute the callback method 00058 @param pMethod : callback method 00059 */ 00060 class CDummy; 00061 template<class T> 00062 void setOnResult( T* pItem, void (T::*pMethod)(uint16_t, uint8_t*, int) ) 00063 { 00064 m_pCb = NULL; 00065 m_pCbItem = (CDummy*) pItem; 00066 m_pCbMeth = (void (CDummy::*)(uint16_t, uint8_t*, int)) pMethod; 00067 } 00068 void clearOnResult(); 00069 00070 void poll(); 00071 void wait(float s); 00072 void wait_ms(int ms); 00073 uint16_t ReportConditionCode[16]; 00074 protected: 00075 int _init(); 00076 void _config(struct stcamcfg* cfg); 00077 void probe_commit_control(struct stcamcfg* cfg); 00078 void onResult(uint16_t frame, uint8_t* buf, int len); 00079 bool m_connect; 00080 bool m_init; 00081 int m_cam; 00082 UsbDevice* m_pDev; 00083 UsbEndpoint* m_pEpIntIn; 00084 UsbEndpoint* m_pEpIsoIn; 00085 int m_width; 00086 int m_height; 00087 int m_payload; 00088 int m_FormatIndex; 00089 int m_FrameIndex; 00090 int m_FrameInterval; 00091 int m_PacketSize; 00092 int m_FrameCount; // 1-8 00093 int m_itdCount; 00094 uint8_t m_int_buf[16]; 00095 int m_int_seq; 00096 int m_iso_seq; 00097 uint16_t m_iso_frame; 00098 usb_stream* m_stream; 00099 CDummy* m_pCbItem; 00100 void (CDummy::*m_pCbMeth)(uint16_t, uint8_t*, int); 00101 void (*m_pCb)(uint16_t, uint8_t*, int); 00102 }; 00103 #endif //UVC_H
Generated on Wed Jul 13 2022 01:34:55 by
1.7.2
