• 关于

    _GET

    的搜索结果

回答

#include <libudev.h> #include <stdio.h> #include <stdlib.h> #include <locale.h> #include <unistd.h> int main (void) { struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct udev_device *dev; /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); exit(1); } /* Create a list of the devices in the 'hidraw' subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, "hidraw"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* For each item enumerated, print out its information. udev_list_entry_foreach is a macro which expands to a loop. The loop will be executed for each member in devices, setting dev_list_entry to a list entry which contains the device's path in /sys. */ udev_list_entry_foreach(dev_list_entry, devices) { const char *path; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ path = udev_list_entry_get_name(dev_list_entry); dev = udev_device_new_from_syspath(udev, path); /* usb_device_get_devnode() returns the path to the device node itself in /dev. */ printf("Device Node Path: %s\n", udev_device_get_devnode(dev)); /* The device pointed to by dev contains information about the hidraw device. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it.*/ dev = udev_device_get_parent_with_subsystem_devtype( dev, "usb", "usb_device"); if (!dev) { printf("Unable to find parent usb device."); exit(1); } /* From here, we can call get_sysattr_value() for each file in the device's /sys entry. The strings passed into these functions (idProduct, idVendor, serial, etc.) correspond directly to the files in the directory which represents the USB device. Note that USB strings are Unicode, UCS2 encoded, but the strings returned from udev_device_get_sysattr_value() are UTF-8 encoded. */ printf(" VID/PID: %s %s\n", udev_device_get_sysattr_value(dev,"idVendor"), udev_device_get_sysattr_value(dev, "idProduct")); printf(" %s\n %s\n", udev_device_get_sysattr_value(dev,"manufacturer"), udev_device_get_sysattr_value(dev,"product")); printf(" serial: %s\n", udev_device_get_sysattr_value(dev, "serial")); udev_device_unref(dev); } /* Free the enumerator object */ udev_enumerate_unref(enumerate); udev_unref(udev); return 0;

云栖技术 2019-12-02 02:35:28 0 浏览量 回答数 0

回答

#include <libudev.h> #include <stdio.h> #include <stdlib.h> #include <locale.h> #include <unistd.h> int main (void) { struct udev *udev; struct udev_enumerate *enumerate; struct udev_list_entry *devices, *dev_list_entry; struct udev_device *dev; /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); exit(1); } /* Create a list of the devices in the 'hidraw' subsystem. */ enumerate = udev_enumerate_new(udev); udev_enumerate_add_match_subsystem(enumerate, "hidraw"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); /* For each item enumerated, print out its information. udev_list_entry_foreach is a macro which expands to a loop. The loop will be executed for each member in devices, setting dev_list_entry to a list entry which contains the device's path in /sys. */ udev_list_entry_foreach(dev_list_entry, devices) { const char *path; /* Get the filename of the /sys entry for the device and create a udev_device object (dev) representing it */ path = udev_list_entry_get_name(dev_list_entry); dev = udev_device_new_from_syspath(udev, path); /* usb_device_get_devnode() returns the path to the device node itself in /dev. */ printf("Device Node Path: %s\n", udev_device_get_devnode(dev)); /* The device pointed to by dev contains information about the hidraw device. In order to get information about the USB device, get the parent device with the subsystem/devtype pair of "usb"/"usb_device". This will be several levels up the tree, but the function will find it.*/ dev = udev_device_get_parent_with_subsystem_devtype( dev, "usb", "usb_device"); if (!dev) { printf("Unable to find parent usb device."); exit(1); } /* From here, we can call get_sysattr_value() for each file in the device's /sys entry. The strings passed into these functions (idProduct, idVendor, serial, etc.) correspond directly to the files in the directory which represents the USB device. Note that USB strings are Unicode, UCS2 encoded, but the strings returned from udev_device_get_sysattr_value() are UTF-8 encoded. */ printf(" VID/PID: %s %s\n", udev_device_get_sysattr_value(dev,"idVendor"), udev_device_get_sysattr_value(dev, "idProduct")); printf(" %s\n %s\n", udev_device_get_sysattr_value(dev,"manufacturer"), udev_device_get_sysattr_value(dev,"product")); printf(" serial: %s\n", udev_device_get_sysattr_value(dev, "serial")); udev_device_unref(dev); } /* Free the enumerator object */ udev_enumerate_unref(enumerate); udev_unref(udev); return 0; }

杨冬芳 2019-12-02 03:08:50 0 浏览量 回答数 0

回答

找到方法了, 可以直接在客户端管理这类异常/超时的查询。 1、直接从客户端获取当前连接的进程id客户端新建jdbc连接conn时,通过执行以下sql获取该链接的后台进程pid:select procpid, start, S.client_host, S.client_port, now() - start as lap, current_queryfrom ( select backendid, pg_stat_get_backend_pid(S.backendid) as procpid, pg_stat_get_backend_activity_start(S.backendid) as start, pg_stat_get_backend_client_addr(S.backendid) as client_host, pg_stat_get_backend_client_port(S.backendid) as client_port, pg_stat_get_backend_activity(S.backendid) as current_query from (select pg_stat_get_backend_idset() as backendid) as S ) as S,( select inet_client_addr() as client_host, inet_client_port() as client_port ) as client where client.client_host = S.client_host and client.client_port = S.client_port; 2、客户端连接池管理线程记录conn<->pid的对应关系 3、当客户端发现该连接conn异常/超时后,结合digoal回答的关闭查询pid的方法,将该pid上的查询关闭。pg_cancel_backend(pid)

pg-learner 2019-12-02 01:52:14 0 浏览量 回答数 0

回答

is_leap_year 判断是否为闰年get_num_of_days_in_month 获得每月的天数get_total_num_of_days 获得自1800年1月1日以来经过的天数get_start_day 获得每月1日为星期几print_month_body 打印日历的数字部分get_month_name 获得每月的名称print_month_title 打印日历标题与头部部分具体实现如下:coding=utf-8author = 'Leonard'def is_leap_year(year):# 判断是否为闰年 if year % 4 == 0 and year % 100 != 0 or year % 400 == 0: return True else: return False def get_num_of_days_in_month(year, month):# 给定年月返回月份的天数 if month in (1, 3, 5, 7, 8, 10, 12): return 31 elif month in (4, 6, 9, 11): return 30 elif is_leap_year(year): return 29 else: return 28 def get_total_num_of_day(year, month):# 自1800年1月1日以来过了多少天 days = 0 for y in range(1800, year): if is_leap_year(y): days += 366 else: days += 365 for m in range(1, month): days += get_num_of_days_in_month(year, m) return days def get_start_day(year, month):# 返回当月1日是星期几,由1800.01.01是星期三推算 return 3 + get_total_num_of_day(year, month) % 7 月份与名称对应的字典month_dict = {1: 'January', 2: 'February', 3: 'March', 4: 'April', 5: 'May', 6: 'June', 7: 'July', 8: 'August', 9: 'September', 10: 'October', 11: 'November', 12: 'December'} def get_month_name(month):# 返回当月的名称 return month_dict[month] def print_month_title(year, month):# 打印日历的首部 print ' ', get_month_name(month), ' ', year, ' ' print '-------------------------------------' print ' Sun Mon Tue Wed Thu Fri Sat ' def print_month_body(year, month):''' 打印日历正文 格式说明:空两个空格,每天的长度为5 需要注意的是print加逗号会多一个空格 ''' i = get_start_day(year, month) if i != 7: print ' ', # 打印行首的两个空格 print ' ' * i, # 从星期几开始则空5*几个空格 for j in range(1, get_num_of_days_in_month(year, month)+1): print '%4d' %j, # 宽度控制,4+1=5 i += 1 if i % 7 == 0: # i用于计数和换行 print ' ' # 每换行一次行首继续空格 主函数部分year = int(raw_input("Please input target year:"))month = int(raw_input("Please input target month:"))print_month_title(year, month)print_month_body(year, month)

世事皆空 2019-12-02 01:09:16 0 浏览量 回答数 0

回答

详细解答可以参考官方帮助文档通过oss_get_object_to_buffer接口,可以实现将文件下载到内存中: aos_pool_t *p;oss_request_options_t *options;aos_status_t *s;aos_table_t *headers;aos_table_t *params;aos_table_t *resp_headers;char *bucket_name = "<您的bucket名字>";char *object_name = "<您的object名字>";aos_string_t bucket;aos_string_t object;aos_list_t buffer;aos_buf_t *content;char *buf;int64_t len = 0;int64_t size = 0;int64_t pos = 0;aos_pool_create(&p, NULL);/* 创建并初始化options */options = oss_request_options_create(p);init_options(options);/* 初始化参数 */aos_str_set(&object, object_name);aos_str_set(&bucket, bucket_name);headers = aos_table_make(p, 0);params = aos_table_make(p, 0);/* 下载文件 */aos_list_init(&buffer);s = oss_get_object_to_buffer(options, &bucket, &object, &buffer, headers, params, &resp_headers);if (aos_status_is_ok(s)) { printf("get object succeeded\n"); /* 将下载内容拷贝到buffer中*/ len = aos_buf_list_len(&buffer); buf = aos_pcalloc(p, len + 1); buf[len] = '\0'; aos_list_for_each_entry(content, &buffer, node) { size = aos_buf_size(content); memcpy(buf + pos, content->pos, size); pos += size; }} else { printf("get object failed\n");}aos_pool_destroy(p); 注: 2.0.0相对于1.0.0版本,oss_get_object_to_buffer接口增加了params参数,同时headers和params允许为NULL,1.0.0及其之前版本不支持为NULLoss_get_object_to_buffer_by_url和oss_get_object_to_file_by_url参数也增加了params参数完整代码参考:GitHub

2019-12-01 23:14:42 0 浏览量 回答数 0

回答

代码: void Tree<T>::creat_tree(TreeNode<T> * &pointer) { //非递归实现对森林的赋值;******************************* T temp; stack<TreeNode<T> *> creat_help; cin>>temp; if(temp=='#') { pointer=NULL; return; } pointer=new TreeNode<T>; pointer->get_val()=temp; creat_help.push(pointer); TreeNode<T> * temp_pointer=pointer; int tag=0; //标志位,值为0,表示处理结点的左孩子,值为1,表示处理结点的右孩子; while(cin>>temp) { if(temp!='#') { if(tag==0) { temp_pointer->get_LeftMostcld()=new TreeNode<T>; temp_pointer->get_LeftMostcld()->get_val()=temp; creat_help.push(temp_pointer->get_LeftMostcld()); temp_pointer=temp_pointer->get_LeftMostcld(); } else { temp_pointer->get_Rightslib()=new TreeNode<T>; temp_pointer->get_Rightslib()->get_val()=temp; creat_help.push(temp_pointer->get_Rightslib()); temp_pointer=temp_pointer->get_Rightslib(); tag=0; } } else { if(tag==0) { temp_pointer->get_LeftMostcld()=NULL; tag=1; } else { temp_pointer->get_Rightslib()=NULL; } if(creat_help.empty()) return; temp_pointer=creat_help.top(); creat_help.pop(); } } }

琴瑟 2019-12-02 01:25:21 0 浏览量 回答数 0

问题

阿里云的IOT 设备端SDK测试失败

big67 2019-12-01 19:35:40 2821 浏览量 回答数 1

问题

虚拟主机的函数限制

飞雪落殇 2019-12-01 21:54:56 6206 浏览量 回答数 1

回答

你好,我也是刚接触IOT SDK,我编译了设备端的SDK,linux版本的,但是运行出错了,请问是什么原因呢?请问有联系方式吗root@custVBOX:mqtt# ./demo start demo![notice] src/aliyun_iot_auth.c:592 aliyun_iot_auth_init()| auth init success![error] src/aliyun_iot_auth.c:145 aliyun_iot_get_response()| auth failed: errorCode: Unknow[error] src/aliyun_iot_auth.c:418 aliyun_iot_get_auth_info()| run aliyun_iot_get_response error![error] src/aliyun_iot_auth.c:726 aliyun_iot_auth()| run aliyun_iot_get_auth_info error!result = -1run aliyun_iot_auth() error![notice] src/aliyun_iot_auth.c:613 aliyun_iot_auth_release()| auth release!out of demo!

big67 2019-12-02 03:17:47 0 浏览量 回答数 0

回答

1.类的定义 代码如下: 复制代码复制代码 !/usr/bin/env python coding:utf8 class Hotel(object): """docstring for Hotel""" def __init__(self, room, cf=1.0, br=15): self.room = room self.cf = cf self.br = br def cacl_all(self, days=1): return (self.room * self.cf + self.br) * days if name == '__main__': stdroom = Hotel(200) big_room = Hotel(230, 0.9) print stdroom.cacl_all() print stdroom.cacl_all(2) print big_room.cacl_all() print big_room.cacl_all(3) 复制代码复制代码 2.父类、子类以及调用父类 代码如下: 复制代码复制代码 !/usr/bin/env python -- coding: utf-8 -- 父类 class AddBook(object): def __init__(self, name, phone): self.name = name self.phone = phone def get_phone(self): return self.phone 子类,继承 class EmplEmail(AddBook): def __init__(self, nm, ph, email): # AddBook.__init__(self, nm, ph) # 调用父类方法一 super(EmplEmail, self).__init__(nm, ph) # 调用父类方法二 self.email = email def get_email(self): return self.email 调用 if name == "__main__": Detian = AddBook('handetian', '18210413001') Meng = AddBook('shaomeng', '18210413002') print Detian.get_phone() print AddBook.get_phone(Meng) alice = EmplEmail('alice', '18210418888', 'alice@xkops.com') print alice.get_email(), alice.get_phone() 复制代码复制代码 3.类的组合使用 代码如下: 复制代码复制代码 !/usr/bin/env python -- coding: utf-8 -- '''1.class类的组合使用2.手机、邮箱、QQ等是可以变化的(定义在一起),姓名不可变(单独定义)。3.在另一个类中引用''' class Info(object): def __init__(self, phone, email, qq): self.phone = phone self.email = email self.qq = qq def get_phone(self): return self.phone def update_phone(self, newphone): self.phone = newphone print "手机号更改已更改" def get_email(self): return self.email class AddrBook(object): '''docstring for AddBook''' def __init__(self, name, phone, email, qq): self.name = name self.info = Info(phone, email, qq) if name == "__main__": Detian = AddrBook('handetian', '18210413001', 'detian@xkops.com', '123456') print Detian.info.get_phone() Detian.info.update_phone(18210413002) print Detian.info.get_phone() print Detian.info.get_email() 复制代码复制代码 4.内置功能(函数()加与不加的区别) 代码如下: 复制代码复制代码 !/usr/bin/env python coding:utf8 class Books(object): def __init__(self, title, author): self.title = title self.author = author def __str__(self): return self.title def __repr__(self): return self.title def __call__(self): print "%s is written by %s" %(self.title, self.author) if name == '__main__': pybook = Books('Core Python', 'Wesley') print pybook pybook() 复制代码 复制代码 复制代码复制代码 !/usr/bin/env python coding:utf8 class Number(object): """Custum object add/radd -> +; sub/rsub -> -; mul/rmul -> *; div/rdiv -> /; """ def __init__(self, number): self.number = number def __add__(self, other): return self.number + other def __radd__(self, other): return self.number + other def __sub__(self, other): return self.number - other def __rsub__(self, other): return other - self.number def __gt__(self, other): if self.number > other: return True return False if name == '__main__': num = Number(10) print num + 20 print 30 + num print num - 5 print 11 - num print num > 20

xuning715 2019-12-02 01:10:24 0 浏览量 回答数 0

问题

存储过程执行报错,请专家指教 ?报错

爱吃鱼的程序员 2020-06-23 21:05:46 0 浏览量 回答数 1

问题

C-SDK之如何实现 下载文件(一)?

青衫无名 2019-12-01 21:45:57 1272 浏览量 回答数 0

回答

1.要知道结点的数据及关系等才行。 2.用new 产生结点; 很简单。-------------------------我是用C++模板写的,希望可以帮助你。 构造方法是:输入一串字符; 如果直接输入#,则是空树;否则则是AB###;即以前序顺序输入; 代码: void Tree<T>::creat_tree(TreeNode<T> * &pointer) { //递归实现对森林的赋值;********************** /*T temp; cin>>temp; if(temp=='#') { pointer=NULL; return; } pointer=new TreeNode<T>; pointer->get_val()=temp; creat_tree(pointer->get_LeftMostcld()); creat_tree(pointer->get_Rightslib());*/ //非递归实现对森林的赋值;******************************* T temp; stack<TreeNode<T> *> creat_help; cin>>temp; if(temp=='#') { pointer=NULL; return; } pointer=new TreeNode<T>; pointer->get_val()=temp; creat_help.push(pointer); TreeNode<T> * temp_pointer=pointer; int tag=0; //标志位,值为0,表示处理结点的左孩子,值为1,表示处理结点的右孩子; while(cin>>temp) { if(temp!='#') { if(tag==0) { temp_pointer->get_LeftMostcld()=new TreeNode<T>; temp_pointer->get_LeftMostcld()->get_val()=temp; creat_help.push(temp_pointer->get_LeftMostcld()); temp_pointer=temp_pointer->get_LeftMostcld(); } else { temp_pointer->get_Rightslib()=new TreeNode<T>; temp_pointer->get_Rightslib()->get_val()=temp; creat_help.push(temp_pointer->get_Rightslib()); temp_pointer=temp_pointer->get_Rightslib(); tag=0; } } else { if(tag==0) { temp_pointer->get_LeftMostcld()=NULL; tag=1; } else { temp_pointer->get_Rightslib()=NULL; } if(creat_help.empty()) return; temp_pointer=creat_help.top(); creat_help.pop(); } } }

boxti 2019-12-02 01:24:52 0 浏览量 回答数 0

回答

详细解答可以参考官方帮助文档通过oss_get_object_to_file接口,可以实现将文件下载到指定文件: aos_pool_t *p;oss_request_options_t *options;aos_status_t *s;aos_table_t *headers;aos_table_t *params;aos_table_t *resp_headers;char *bucket_name = "<您的bucket名字>";char *object_name = "<您的object名字>";char *filepath = "<本地文件路径>";aos_string_t bucket;aos_string_t object;aos_string_t file;aos_pool_create(&p, NULL);/* 创建并初始化options */options = oss_request_options_create(p);init_options(options);/* 初始化参数 */aos_str_set(&bucket, bucket_name);aos_str_set(&object, object_name);aos_str_set(&file, filepath);headers = aos_table_make(p, 0);params = aos_table_make(p, 0);/* 下载文件 */s = oss_get_object_to_file(options, &bucket, &object, &file, headers, params, &resp_headers);if (aos_status_is_ok(s)) { printf("get object succeeded\n");} else { printf("get object failed\n");}aos_pool_destroy(p); 注: 2.0.0相对于1.0.0版本,oss_get_object_to_file接口增加了params参数,同时headerss和params允许为NULL,1.0.0及其之前版本不支持为NULL。如果本地有同名文件 filepath,本地文件将会被覆盖;完整代码参考:GitHub

2019-12-01 23:14:42 0 浏览量 回答数 0

问题

借用贵宝地,请PHP高手帮忙看看这个代码错在哪里?

wdlm.cn 2019-12-01 20:53:57 5016 浏览量 回答数 3

问题

SqlParameterCollection仅接受非null的SqlParameter类型对象,而不

祖安文状元 2020-01-04 15:46:23 0 浏览量 回答数 1

问题

asp 遍历问题 声明的变量与参数的关系

小旋风柴进 2019-12-01 19:47:10 917 浏览量 回答数 1

回答

Re如何开启filegetcontents 转的: file_get_contents函数的使用示例: < ?php $file_contents = file_get_contents('http://www.ccvita.com/'); echo $file_contents; ?> 换成curl函数的使用示例: < ?php $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, 'http://www.ccvita.com'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); echo $file_contents; ?> 利用function_exists函数来判断php是否支持一个函数可以轻松写出下面函数 < ?php function vita_get_url_content($url) { if(function_exists('file_get_contents')) { $file_contents = file_get_contents($url); } else { $ch = curl_init(); $timeout = 5; curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $file_contents = curl_exec($ch); curl_close($ch); } return $file_contents; } ?> 其实上面的这个函数还有待商榷,如果你的主机服务商把file_get_contents和curl都关闭了,上面的函数就会出现错误。

shanw 2019-12-02 02:05:25 0 浏览量 回答数 0

问题

pip install 报错?报错

爱吃鱼的程序员 2020-06-14 16:19:45 0 浏览量 回答数 1

问题

C-SDK - 前言

青衫无名 2019-12-01 21:45:15 1008 浏览量 回答数 0

问题

语音回执消息---Python(2)

猫饭先生 2019-12-01 20:59:04 969 浏览量 回答数 0

问题

如何利用python脚本启动spring boot项目?? 400 报错

爱吃鱼的程序员 2020-06-04 16:30:27 1 浏览量 回答数 1

回答

Re借用贵宝地,请PHP高手帮忙看看这个代码错在哪里? 是这个试试<?php if ( get_post_meta($post->ID, 'from_site_name', true) && get_post_meta($post->ID, 'from_site_url', true) ) { ?> <a href="<?php echo get_post_meta($post->ID, "from_site_url", true); ?>" target="_blank"><?php echo get_post_meta($post->ID, "from_site_name", true); ?></a> <?php } elseif ( get_post_meta($post->ID, 'from_site_name', true) ) { ?> <?php echo get_post_meta($post->ID, "from_site_name", true); ?></a> <?php } elseif ( get_post_meta($post->ID, 'from_site_url', true) ) { ?> <a href="<?php echo get_post_meta($post->ID, "from_site_url", true); ?>" target="_blank">网络</a> <?php } else {?> 本站 <?php } ?>

天之城 2019-12-01 23:53:51 0 浏览量 回答数 0

问题

无法在Python中获取Twitter用户配置文件数据

几许相思几点泪 2019-12-23 17:56:51 0 浏览量 回答数 0

问题

如何查找流量回执消息(2)

猫饭先生 2019-12-01 20:59:41 857 浏览量 回答数 0

回答

代码中添加if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map(’stripslashes_deep’, $value) : stripslashes($value); return $value; } $_POST = array_map(’stripslashes_deep’, $_POST); $_GET = array_map(’stripslashes_deep’, $_GET); $_COOKIE = array_map(’stripslashes_deep’, $_COOKIE); }

落地花开啦 2019-12-02 02:45:30 0 浏览量 回答数 0

问题

PHP,MySQL错误:列数与第1行的值数不匹配

保持可爱mmm 2020-05-11 11:11:39 1 浏览量 回答数 1

回答

#include <iostream> using namespace std; int maxd(int y, int m) { switch (m) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; case 2: if (y % 4 != 0) return 28; if (y % 100 == 0 && y % 400 != 0) return 28; return 29; default: return 30; } } class Date{ private: int day, month, year; static Date default_date; //初始化为 1901年1月1日 public: Date(){ day=month=year=0; } Date(int d, int m, int y); //构造函数 int get_day() const; // 返回day int get_month() const; //返回month int get_year() const; // 返回year static void set_default(int, int, int){Date::default_date = Date(1, 1, 1901);} static int get_default_day() {return Date::default_date.get_day();} //返回缺省day static int get_default_month(){return Date::default_date.get_month();} //返回缺省month static int get_default_year(){return Date::default_date.get_year();} //返回缺省year Date& add_year(int n); //加n年 Date& add_month(int n); //加n月,考虑超过12月,考虑闰年 Date& add_day(int n); //加n天,考虑进位月和年,考虑闰年 }; Date::Date(int d, int m, int y) { day = d; month = m; year = y; } int Date::get_day() const { return day; } int Date::get_month() const { return month; } int Date::get_year() const { return year; } Date& Date::add_year(int n) { year += n; return *this; } Date& Date::add_month(int n) { if (month + n <= 12) { month += n; return *this; } add_year(1); n = n - 12 + month; month = 1; while (n >= 12) { add_year(1); n -= 12; } month += n; return *this; } Date& Date::add_day(int n) { if (day + n <= maxd(year, month)) { day += n; return *this; } add_month(1); n = n - (maxd(year, month), day) + day; day = 1; while (n >= maxd(year, month)) { add_month(1); n -= maxd(year, month); } day += n; return *this; } int main(){ char type[110]; int day,mon,year; int addday,addmon,addyear; while(cin>>type){ if(strcmp(type,"Date") == 0){ cin>>day>>mon>>year; Date mydate(day,mon,year); cin>>addday>>addmon>>addyear; mydate.add_day(addday).add_month(addmon).add_year(addyear); cout << mydate.get_day() << " " << mydate.get_month() << " " << mydate.get_year() << endl; }else if(strcmp(type,"defalutDate") == 0){ cout << Date::get_default_day() << " " << Date::get_default_month() << " " << Date::get_default_year() << endl; }else if(strcmp(type,"setdefaultDate") == 0){ cin>>day>>mon>>year; Date::set_default(day,mon,year); cout << Date::get_default_day() << " " << Date::get_default_month() << " " << Date::get_default_year() << endl; } } return 0; }

a123456678 2019-12-02 02:01:43 0 浏览量 回答数 0

回答

我更喜欢使用cv2的图像,你可以将此代码放在research / object_detection路径为 detect_object.py 文件必须放在这里: model-master/research/object_detection/detect_object.py import numpy as npimport osimport six.moves.urllib as urllibimport sysimport tarfileimport tensorflow as tfimport zipfile from distutils.version import StrictVersionfrom collections import defaultdictfrom io import StringIOimport cv2 This is needed since the notebook is stored in the object_detection folder. sys.path.append("..")from object_detection.utils import ops as utils_ops if StrictVersion(tf.__version__) < StrictVersion('1.9.0'): raise ImportError('Please upgrade your TensorFlow installation to v1.9.* or later!') Object detection imports Here are the imports from the object detection module. from utils import label_map_util from utils import visualization_utils as vis_util What model to download. MODEL_NAME = 'ssd_mobilenet_v1_coco_2017_11_17'MODEL_FILE = MODEL_NAME + '.tar.gz'DOWNLOAD_BASE = 'http://download.tensorflow.org/models/object_detection/' Path to frozen detection graph. This is the actual model that is used for the object detection. PATH_TO_FROZEN_GRAPH = MODEL_NAME + '/frozen_inference_graph.pb' List of the strings that is used to add correct label for each box. PATH_TO_LABELS = os.path.join('data', 'mscoco_label_map.pbtxt') opener = urllib.request.URLopener() opener.retrieve(DOWNLOAD_BASE + MODEL_FILE, MODEL_FILE) tar_file = tarfile.open(MODEL_FILE)for file in tar_file.getmembers(): file_name = os.path.basename(file.name) if 'frozen_inference_graph.pb' in file_name: tar_file.extract(file, os.getcwd()) detection_graph = tf.Graph()with detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(PATH_TO_FROZEN_GRAPH, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') In[31]: category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True) Size, in inches, of the output images. IMAGE_SIZE = (12, 8) def run_inference_for_single_image(image, graph): with graph.as_default(): with tf.Session() as sess: # Get handles to input and output tensors ops = tf.get_default_graph().get_operations() all_tensor_names = {output.name for op in ops for output in op.outputs} tensor_dict = {} for key in [ 'num_detections', 'detection_boxes', 'detection_scores', 'detection_classes', 'detection_masks' ]: tensor_name = key + ':0' if tensor_name in all_tensor_names: tensor_dict[key] = tf.get_default_graph().get_tensor_by_name( tensor_name) if 'detection_masks' in tensor_dict: # The following processing is only for single image detection_boxes = tf.squeeze(tensor_dict['detection_boxes'], [0]) detection_masks = tf.squeeze(tensor_dict['detection_masks'], [0]) # Reframe is required to translate mask from box coordinates to image coordinates and fit the image size. real_num_detection = tf.cast(tensor_dict['num_detections'][0], tf.int32) detection_boxes = tf.slice(detection_boxes, [0, 0], [real_num_detection, -1]) detection_masks = tf.slice(detection_masks, [0, 0, 0], [real_num_detection, -1, -1]) detection_masks_reframed = utils_ops.reframe_box_masks_to_image_masks( detection_masks, detection_boxes, image.shape[0], image.shape[1]) detection_masks_reframed = tf.cast( tf.greater(detection_masks_reframed, 0.5), tf.uint8) # Follow the convention by adding back the batch dimension tensor_dict['detection_masks'] = tf.expand_dims( detection_masks_reframed, 0) image_tensor = tf.get_default_graph().get_tensor_by_name('image_tensor:0') # Run inference output_dict = sess.run(tensor_dict, feed_dict={image_tensor: np.expand_dims(image, 0)}) # all outputs are float32 numpy arrays, so convert types as appropriate output_dict['num_detections'] = int(output_dict['num_detections'][0]) output_dict['detection_classes'] = output_dict[ 'detection_classes'][0].astype(np.uint8) output_dict['detection_boxes'] = output_dict['detection_boxes'][0] output_dict['detection_scores'] = output_dict['detection_scores'][0] if 'detection_masks' in output_dict: output_dict['detection_masks'] = output_dict['detection_masks'][0] return output_dict image = cv2.imread("test_images/image1.jpg") the array based representation of the image will be used later in order to prepare the result image with boxes and labels on it. image_np = load_image_into_numpy_array(image) Expand dimensions since the model expects images to have shape: [1, None, None, 3] image_np_expanded = np.expand_dims(image, axis=0) Actual detection. output_dict = run_inference_for_single_image(image, detection_graph) vis_util.visualize_boxes_and_labels_on_image_array( image, output_dict['detection_boxes'], output_dict['detection_classes'], output_dict['detection_scores'], category_index, instance_masks=output_dict.get('detection_masks'), use_normalized_coordinates=True, line_thickness=8) cv2.imshow("",image)

一码平川MACHEL 2019-12-02 01:57:39 0 浏览量 回答数 0

问题

无法正确调用Python中的类的访问器方法

is大龙 2020-03-24 21:37:07 0 浏览量 回答数 1
阿里云大学 云服务器ECS com域名 网站域名whois查询 开发者平台 小程序定制 小程序开发 国内短信套餐包 开发者技术与产品 云数据库 图像识别 开发者问答 阿里云建站 阿里云备案 云市场 万网 阿里云帮助文档 免费套餐 开发者工具 企业信息查询 小程序开发制作 视频内容分析 企业网站制作 视频集锦 代理记账服务 企业建站模板