完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有样本代码测试相机流从FX3时,连接相机,我必须执行的中断转移的一侧时,相机开始流,
我有一个FX3板和摄像头连接,我用了LUBVC和LIUBB库,用OpenCV,我用过的代码做的, 包括:“LIPUVC/LIPUVC.H”,包括“LIPUVC/LIBUVC.I.H”“包括”和“STDLIB”。包含和lt;STDIO。lopvv2/imgCODECs。oppv2/VelooIo.Hpp& gt;lpop.lt;opencv2/opencv.Hpp&gt;lp:& lt;线程& gt;使用命名空间STD;使用命名空间cv;无效cb(uvcx框架*t*框架,Vault*pTR){uvcgFrimeT*bgr;uvcsiErrRoRo.t RET;iPlIMAGI*CVIMG;int WID= FR OpenCV2/IMGPRO.HPP & Gt;Am & Gt;宽度;ItHe=框架-gt;高度;未签名的短数据DAT[WID*Hi];未签名的CHAR*ByTeDATA =(未签名CHAR *)帧-gt;数据;(int II=0;ii和lt;WID*HII;II++){DATA16[II]=(未签名短)(ByTeDATA [2×II])(ByTeDATA〔2*II+1〕& lt;太阳镜::}:::Mimax LoC(Bayer,M&Max,A&MAX);CV::MATBGMAT(WID,HEI,CVY16UC3);CVTHOLL(Bayer,BGRMAT,CVH-BayBelg2RGB);CV::PyrPoT(BGRMAT,BGRMAT);CVP:BrGATP(BGRMAT,BGRMAT);BGRMAT。转换(BGRMAT,CVY8UC3);拜耳。转换(拜耳,CVY8UC3);γIF 0端。EI,WID,CVY16UC1,(空隙*)数据16;双min,max;CV如果简历::namedwindow(“测试”,cv_window_autosize);简历::imshow(“测试”,bgrmat);简历::WaitKey(1);}无效task1() {结构libu***_device_handle * u***_devh;uvc_device_handle_t * internal_devh;结构libu***_device_descriptor desc;uvc_device_t *开发;int结果;int recv;unsigned char data_in [ 4 ];结果=自由u***_open(开发- >;u***_dev,&;u***_devh);fprintf(stderr,“结果%dn”,结果);} int main(int argc、argv char *){ uvc_context_t * CTX;uvc_error_t RES;uvc_device_t *开发;uvc_device_handle_t * devh;uvc_stream_ctrl_t Ctrl;结构libu***_device_handle * u***_devh;结构libu***_device_descriptor desc;分辨率= uvc_init(&;CTX、空);如果(RES & lt;0){ uvc_perror(RES,“uvc_init”);返回RES;}提出(“UVC初始化”);分辨率= uvc_find_device(CTX,&;开发,0, 0,null);如果(RES & lt;0){ uvc_perror(RES,“uvc_find_device”);} {把别人(“设备”);分辨率= uvc_open(dev,&;devh);如果(RES & lt;0){ uvc_perror(RES,“uvc_open”);} {把别人(“设备打开”);uvc_print_diag(devh,stderr);分辨率= uvc_get_stream_ctrl_format_size(devh,&;Ctrl,uvc_frame_format_yuyv,400, 400, 30);uvc_print_stream_ctrl(&;Ctrl,stderr);如果(RES & lt;0){ uvc_perror(RES,“get_mode”);}否则{ int假人;返回结果;分辨率= uvc_start_streaming(devh,&;Ctrl,CB,&;假人,0);如果(RES & lt;0){ uvc_perror(RES,“start_streaming”);} {把别人(“流10秒…”);uvc_error_t resaemode = uvc_set_ae_mode(devh,1);uvc_perror(resaemode,“set_ae_mode”);int i;unsigned char data_in [ 4 ];在T:;而(1){结果= libu***_interrupt_transfer(devh - >;u***_devh,0x82,data_in,4,&;recv,1000);printf(“%d”,结果);为(int i = 0;我& lt;接收;i++){ printf(“% 02x”,data_in [我]);} printf(“n”);}睡眠(1);// }睡眠(200);uvc_stop_streaming(devh);把(“做流。”);} } uvc_clo硒(devh);把(“设备关闭”);} uvc_unref_device(DEV);} uvc_exit(CTX);把(“UVC退出”);return 0;} 我已经测试了中断传输和相机流分开,这是工作的罚款。 以上来自于百度翻译 以下为原文 I have sample code for testing the camera streaming from the fx3 when connecting the camera, I have to perform the interrupt transfer by the side when the camera starts streaming, I have an fx3 board and camera connected, I have used the libuvc and libu*** libraries with opencv, I have used in the code to do, #include #include #include #include #include "libuvc/libuvc.h" #include "libuvc/libuvc_internal.h" #include #include #include #include #include #include #include #include #include using namespace std; using namespace cv; void cb(uvc_frame_t *frame, void *ptr) { uvc_frame_t *bgr; uvc_error_t ret; IplImage* cvImg; int wid = frame->width; int hei = frame->height; unsigned short data16[wid*hei]; unsigned char * bytedata = (unsigned char*) frame->data; for(int ii=0; ii < wid*hei; ii++) { data16[ii = (unsigned short) (bytedata[2*ii]) | (unsigned short) (bytedata[2*ii+1 << :sunglasses: ; } cv::Mat Bayer( hei, wid, CV_16UC1, (void*) data16); double min, max; cv::minMaxLoc(Bayer, &min, &max); cv::Mat bgrmat(wid,hei,CV_16UC3); cv::cvtColor(Bayer, bgrmat, CV_BayerBG2RGB); cv::pyrDown(bgrmat,bgrmat); cv::pyrUp(bgrmat,bgrmat); bgrmat.convertTo(bgrmat,CV_8UC3); Bayer.convertTo(Bayer,CV_8UC3); #if 0 #endif cv::namedWindow("Test", CV_WINDOW_AUTOSIZE); cv::imshow("Test", bgrmat); cv::waitKey(1); } void task1() { struct libu***_device_handle *u***_devh; uvc_device_handle_t *internal_devh; struct libu***_device_descriptor desc; uvc_device_t *dev; int result; int recv; unsigned char data_in[4]; result = libu***_open(dev->u***_dev, &u***_devh); fprintf(stderr, " result %dn", result); } int main(int argc, char **argv) { uvc_context_t *ctx; uvc_error_t res; uvc_device_t *dev; uvc_device_handle_t *devh; uvc_stream_ctrl_t ctrl; struct libu***_device_handle *u***_devh; struct libu***_device_descriptor desc; res = uvc_init(&ctx, NULL); if (res < 0) { uvc_perror(res, "uvc_init"); return res; } puts("UVC initialized"); res = uvc_find_device( ctx, &dev, 0, 0, NULL); if (res < 0) { uvc_perror(res, "uvc_find_device"); } else { puts("Device found"); res = uvc_open(dev, &devh); if (res < 0) { uvc_perror(res, "uvc_open"); } else { puts("Device opened"); uvc_print_diag(devh, stderr); res = uvc_get_stream_ctrl_format_size( devh, &ctrl, UVC_FRAME_FORMAT_YUYV, 400, 400, 30); uvc_print_stream_ctrl(&ctrl, stderr); if (res < 0) { uvc_perror(res, "get_mode"); } else { int dummy; int result; res = uvc_start_streaming(devh, &ctrl, cb,&dummy, 0); if (res < 0) { uvc_perror(res, "start_streaming"); } else { puts("Streaming for 10 seconds..."); uvc_error_t resAEMODE = uvc_set_ae_mode(devh, 1); uvc_perror(resAEMODE, "set_ae_mode"); int i; unsigned char data_in[4]; int recv; while(1){ result = libu***_interrupt_transfer(devh->u***_devh, 0x82, data_in, 4, &recv, 1000); printf("%d",result); for(int i = 0; i < recv; i++) { printf("%02x ",data_in[i]); } printf("n"); } sleep(1); // } sleep(200); uvc_stop_streaming(devh); puts("Done streaming."); } } uvc_close(devh); puts("Device closed"); } uvc_unref_device(dev); } uvc_exit(ctx); puts("UVC exited"); return 0; } I have tested the interrupt transfer and camera streaming separately, which is working fine. |
|
相关推荐
1个回答
|
|
你好,
当你尝试转会时,你到底面临什么问题? 当做, - Madhu Sudhan 以上来自于百度翻译 以下为原文 Hi, What issue are you exactly facing when you tried to do the transfer? Regards, - Madhu Sudhan |
|
|
|
只有小组成员才能发言,加入小组>>
754个成员聚集在这个小组
加入小组2110 浏览 1 评论
1858 浏览 1 评论
3673 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1791 浏览 6 评论
1540 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
575浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
428浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
440浏览 2评论
390浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
924浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-27 06:44 , Processed in 1.063998 second(s), Total 78, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号