def getPairs(id): label_root = kittiRoot + "instances/" + id image_root = label_root.replace('instances', 'images') image_list = make_dataset(image_root, suffix='.png') image_list.sort() label_list = make_dataset(label_root, suffix='.png') label_list.sort() imgs_list = [] # filter out images with no cars for ind, image_path in enumerate(image_list): label_path = label_list[ind] label = np.array(Image.open(label_path)) plt.imshow(label) plt.show() # for car #mask = np.logical_and(label >= label_id * 1000, label < (label_id + 1) * 1000) mask = np.logical_and(label > 0,label < 3) obj_ids = np.unique(label[mask]).tolist() if len(obj_ids) < 1: continue imgs_list.append('/'.join(image_path.split('/')[-2:])) return imgs_list
时间: 2024-02-26 10:55:14 浏览: 26
这段代码的作用是从指定路径下的标签图像和相应的原始图像中,筛选出含有车辆的图像,并返回这些图像的路径列表。具体实现过程如下:
1. 根据指定的参数 id,生成标签图像和原始图像的路径。
2. 分别读取标签图像和原始图像的路径列表,并按照文件名排序。
3. 构建一个空列表 imgs_list,用于存储含有车辆的图像路径。
4. 遍历原始图像路径列表,依次读取对应位置的标签图像和原始图像。
5. 对于每个原始图像,根据标签图像中像素的值,筛选出含有车辆的像素,并得到这些像素对应的车辆 ID。
6. 如果当前原始图像中不存在车辆,则直接跳过。
7. 否则,将当前原始图像的路径加入 imgs_list 中。
8. 最后,返回所有含有车辆的原始图像路径列表。
相关问题
CalendarContract.Instances.CONTENT_URIUnknown URL content://com.android.calendar/instances/when报错
如果你在使用 `CalendarContract.Instances.CONTENT_URI` 进行查询时出现了 `Unknown URL content://com.android.calendar/instances/when` 的错误,可能是因为你在查询时使用了 `when` 这个参数,而该参数已经在 Android 4.0 中被废弃了。
Android 4.0 之前的版本是支持通过 `content://com.android.calendar/instances/when` URI 进行查询的,但是从 Android 4.0 开始,这个 URI 就被废弃了。如果你需要查询某个时间段内的日历事件,可以使用 `CalendarContract.Instances.CONTENT_URI` 这个 URI,如下所示:
```
long startMillis = ...;
long endMillis = ...;
Cursor cursor = getContentResolver().query(
CalendarContract.Instances.CONTENT_URI,
new String[] { ... },
CalendarContract.Instances.BEGIN + " >= " + startMillis + " AND " + CalendarContract.Instances.END + " <= " + endMillis,
null,
CalendarContract.Instances.BEGIN + " ASC"
);
```
以上代码可以查询指定时间段内的日历事件,并按照开始时间升序排序。注意,`startMillis` 和 `endMillis` 分别表示需要查询的时间段的起始时间和结束时间,单位为毫秒。
CalendarContract.Instances.CONTENT_URIUnknown URL content://com.android.calendar/instances/when
这是一个 Android Calendar Provider 中的 URI,用于查询某个时间段内的所有日历事件。具体来说,这个 URI 对应的是 Instances 表,表示某个日历事件在时间轴上的实例。当我们需要查询某个时间段内的所有日历事件时,可以使用这个 URI 进行查询。例如,我们可以通过该 URI 查询明天的日历事件,如下所示:
```
long start = System.currentTimeMillis() + DateUtils.DAY_IN_MILLIS;
long end = start + DateUtils.DAY_IN_MILLIS;
Cursor cursor = getContentResolver().query(CalendarContract.Instances.CONTENT_URI,
null,
CalendarContract.Instances.DTSTART + ">=? and "+ CalendarContract.Instances.DTSTART + "<=?",
new String[]{String.valueOf(start), String.valueOf(end)},
CalendarContract.Instances.DTSTART + " ASC");
```
这段代码会查询明天的所有日历事件,并按照开始时间升序排序。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)