selective search生成.mat文件
https://github.com/sergeyk/selective_search_ijcv_with_python 里的selective_search.py是python接口
import tempfile
import subprocess
import shlex
import os
import numpy as np
import scipy.io script_dirname = os.path.abspath(os.path.dirname(__file__)) def get_windows(image_fnames, cmd='selective_search'):
"""
Run MATLAB Selective Search code on the given image filenames to
generate window proposals. Parameters
----------
image_filenames: strings
Paths to images to run on.
cmd: string
selective search function to call:
- 'selective_search' for a few quick proposals
- 'selective_seach_rcnn' for R-CNN configuration for more coverage.
"""
# Form the MATLAB script command that processes images and write to
# temporary results file.
f, output_filename = tempfile.mkstemp(suffix='.mat')
os.close(f)
fnames_cell = '{' + ','.join("'{}'".format(x) for x in image_fnames) + '}'
command = "{}({}, '{}')".format(cmd, fnames_cell, output_filename)
print(command) # Execute command in MATLAB.
mc = "matlab -nojvm -r \"try; {}; catch; exit; end; exit\"".format(command)
pid = subprocess.Popen(
shlex.split(mc), stdout=open('/dev/null', 'w'), cwd=script_dirname)
retcode = pid.wait()
if retcode != 0:
raise Exception("Matlab script did not exit successfully!") # Read the results and undo Matlab's 1-based indexing.
all_boxes = list(scipy.io.loadmat(output_filename)['all_boxes'][0])
subtractor = np.array((1, 1, 0, 0))[np.newaxis, :]
all_boxes = [boxes - subtractor for boxes in all_boxes] # Remove temporary file, and return.
os.remove(output_filename)
if len(all_boxes) != len(image_fnames):
raise Exception("Something went wrong computing the windows!")
return all_boxes if __name__ == '__main__':
"""
Run a demo.
"""
import time image_filenames = [
script_dirname + '/000015.jpg',
script_dirname + '/cat.jpg'
]*4
t = time.time()
boxes = get_windows(image_filenames)
print(boxes[:2])
print("Processed {} images in {:.3f} s".format(
len(image_filenames), time.time() - t))
直接运行不会产生.mat文件,而是如图:

把os.remove(output_filename)这句注释掉就可以在/tmp目录下找到文件。
selective search生成.mat文件的更多相关文章
- matlab结构体形式保存数据生成.mat文件< 转>
2015年 参加天池大数据竞赛 为了建立模型,打算基于matlab使用Random Forest Algorithm的工具包 该工具包我在此分享给大家,http://yunpan.cn/cVX ...
- matlab 生成mat文件
生成MAT文件 假如你的矩阵A.B都已赋值,现在需要将A,B矩阵保存成mat格式文件,执行如下命令:save mydata A B 就会把A B矩阵数据保存在yourdata.dat文件中了 保存指定 ...
- Visual Studio 控制台应用程序 同时使用OpenCV和matlab mat文件操作
matalb具有灵活的图像处理,代码编写起来简洁而高效.而OpenCV具有很多成熟的计算机视觉算法,能够处理很多实时的识别处理等问题,而且代码运行起来效率很高.所以如何结合两者之间的优点,是让很多学术 ...
- 生成hprof文件,用MAT进行分析
生成hprof文件可以在DDMS选中进程点击窗口左上角的"dump hprof file"按钮来直接生成,也可以通过在程序加代码中来生成 代码2: void generateHpr ...
- 将Mat类型坐标数据生成pts文件
前言 获取人脸特征点的坐标信息之后,想要将坐标信息shape保存为pts/asf/txt等文件格式,本文就对此进行实现. 实现过程 1.确定pts文件的书写格式: 以要生成的文件为例,书写格式如下: ...
- 第三十三节,目标检测之选择性搜索-Selective Search
在基于深度学习的目标检测算法的综述 那一节中我们提到基于区域提名的目标检测中广泛使用的选择性搜索算法.并且该算法后来被应用到了R-CNN,SPP-Net,Fast R-CNN中.因此我认为还是有研究的 ...
- 目标检测之选择性搜索-Selective Search
一.滑动窗口检测器 一种用于目标检测的暴力方法就是从左到右,从上到下滑动窗口,利用分类识别目标.为了在不同观察距离处检测不同的目标类型,我们可以使用不同大小和宽高比的窗口 得到窗口内的图片送入分类器, ...
- Selective Search for Object Recognition 论文笔记【图片目标分割】
这篇笔记,仅仅是对选择性算法介绍一下原理性知识,不对公式进行推倒. 前言: 这篇论文介绍的是,如果快速的找到的可能是物体目标的区域,不像使用传统的滑动窗口来暴力进行区域识别.这里是使用算法从多个维度对 ...
- 【Android Studio安装部署系列】二十五、Android studio使用NDK生成so文件和arr文件
版权声明:本文为HaiyuKing原创文章,转载请注明出处! 概述 Android Studio使用ndk的简单步骤. NDK环境搭建 下载NDK 下载链接:https://developer.and ...
随机推荐
- Linux查看系统位数
查看linux是多少位的几位方法 方法/步骤 方法一:getconf LONG_BIT 在linux终端输入getconf LONG_BIT命令 如果是32位机器,则结果为32 Linux ...
- centos7 yum快速安装php7.1
1. 安装nginx yum install nginx ##开启nginx service nginx start 2.安装MYSQLyum localinstall http://dev.mysq ...
- element input搜索框探索
转(https://blog.csdn.net/qq_37746973/article/details/78402812) 在script中添加下面两个函数 //queryString 为在框中输入的 ...
- java资料
HTML5+CSS3视频教程:http://pan.baidu.com/s/1hsyOjze 密码:c3uw JavaScript视频教程:链接:http://pan.baidu.com/s/1 ...
- 统计分析: 跨库多表join
mysql中如果多个库在一个实例上, 可以进行多表的跨库Join, 但是如果后期数据库分隔到不同的实例机器上,有查询问题 mysql的查询优化器没有其他商业数据库做的好, 用来CRUD还行, 但是做大 ...
- jQuery-How to Create a Basic Plugin
官方插件:http://learn.jquery.com/plugins/basic-plugin-creation/ $.extend方法和$.fn.extend方法都可以用来扩展jQuery功能. ...
- IDEA使用汇总
1. 常用配置 File --> Settings (Ctrl + Alt + S) 1).提示不区分大小写: Editor-->Genereal-->Code Completion ...
- MyEclipse8.5配置struts等框架
开发环境:MyEclipse8.5+Tomcat6.5+MySql5.5配置环境:Struts2+Spring2+Hibernate3.1 1.首先创建Java-Web Project工程,选择J2E ...
- WCF SecurityElement
1.SslStreamSecurityElement <sslStreamSecurity requireClientCertificate="true"/> Requ ...
- i++ ++i i=i+1 和i+=1
这几个运算符的差别总是过一段时间就爱搞混,每次需要百度,还是自己记录一下方便查阅. int i=0; System.out.println(i++); 输出:0 int i=0; System.out ...