phpstrom支持基于PSR2的代码检查的步骤

使用composer全局安装
修改 composer 的全局配置文件(推荐方式)
打开命令行窗口(windows用户)或控制台(Linux、Mac 用户)并执行如下命令:

 composer config -g repo.packagist composer https://packagist.phpcomposer.com
 composer global require "squizlabs/php_codesniffer=*"
 注:windows系统,会在C:\Users\{user name}\AppData\Roaming\Composer\vendor\bin下生成一个phpcs.bat文件,这个是phpstorm后续设置需要用到的文件

phpstorm设置
步骤一

步骤二

步骤三

步骤四

显示OK,代码格式不对,会提示波浪线,想要更清楚,自行更改主题格式
步骤五

代码风格文档

https://www.kancloud.cn/thinkphp/php-fig-psr/3141

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
由于不知道您具体需要的是哪方面的PSR Matlab代码,以下提供两个常见的PSR算法的Matlab实现供参考: 1. 基于DWT和PSR的图像检测算法: ```matlab function [r, c, metric] = psr_detector(im, w, pfa, gamma) % PSR_DETECTOR - detect peaks using the PSR (Pulse Similarity Radar) algorithm % % Usage: [r, c, metric] = psr_detector(im, w, pfa, gamma) % % Arguments: % im - nxm image array % w - nwinx2 matrix specifying the dimensions of the sliding % window used to scan the image. Each row of the matrix % has the form [height width]. % pfa - false alarm probability (default 0.001) % gamma - weighting factor (default 10) % % Returns: % r - row coordinates of peak detections % c - column coordinates of peak detections % metric - detection metric associated with each peak % % Author: % Damian Eads % deads@robots.ox.ac.uk % % References: % Eads, D., and Noble, J. "Pulse similarity radar for object detection," % in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, % 2007, pp. 1-8. % % Noble, J.A., and Brady, J.M. "Pulse-coupled neural networks," % IEEE Trans. Neural Networks, vol. 14, no. 6, 2003, pp. 1562-1573. if nargin < 3 pfa = 0.001; end if nargin < 4 gamma = 10; end % determine the size of each window nwin = size(w, 1); [nrows, ncols] = size(im); % precompute window areas areas = w(:, 1) .* w(:, 2); % precompute gamma * area(w) * log(1 / pfa) gamma_areas_log = gamma * areas * log(1 / pfa); % precompute the psr threshold for each window size psr_thresholds = zeros(nwin, 1); for i = 1:nwin psr_thresholds(i) = sqrt(gamma_areas_log(i) + 2 * gamma * areas(i)); end % perform the detection r = []; c = []; metric = []; for i = 1:nwin % get the size of this window h = w(i, 1); w_ = w(i, 2); % pad the image padded_im = padarray(im, [h, w_], 'replicate', 'both'); % compute the threshold thresh = psr_thresholds(i); % scan the image for r_ = 1:(nrows + h) for c_ = 1:(ncols + w_) % extract the window window = padded_im(r_:(r_ + h - 1), c_:(c_ + w_ - 1)); % compute the mean and standard deviation window_mean = mean(window(:)); window_stddev = std(window(:)); % compute the psr psr = (window_mean - thresh) / window_stddev; % if the psr is greater than the threshold, add the detection if psr > 0 r(end + 1) = r_ - h; c(end + 1) = c_ - w_; metric(end + 1) = psr; end end end end end ``` 2. 基于小波变换和PSR的视频运动目标检测算法: ```matlab function [bbox, score] = psr_motion_detection(video_file, w, pfa, gamma, show_result) % PSR_MOTION_DETECTION - detect motion targets using the PSR (Pulse Similarity Radar) algorithm % % Usage: [bbox, score] = psr_motion_detection(video_file, w, pfa, gamma, show_result) % % Arguments: % video_file - the input video file name % w - nwinx2 matrix specifying the dimensions of the sliding % window used to scan the image. Each row of the matrix % has the form [height width]. % pfa - false alarm probability (default 0.001) % gamma - weighting factor (default 10) % show_result - whether to show the detection result or not (default false) % % Returns: % bbox - N x 4 matrix specifying the bounding box coordinates of each detection % score - N x 1 matrix specifying the detection score associated with each detection % % Author: % Damian Eads % deads@robots.ox.ac.uk % % References: % Eads, D., and Noble, J. "Pulse similarity radar for object detection," % in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, % 2007, pp. 1-8. % % Noble, J.A., and Brady, J.M. "Pulse-coupled neural networks," % IEEE Trans. Neural Networks, vol. 14, no. 6, 2003, pp. 1562-1573. if nargin < 3 pfa = 0.001; end if nargin < 4 gamma = 10; end if nargin < 5 show_result = false; end % determine the size of each window nwin = size(w, 1); % precompute window areas areas = w(:, 1) .* w(:, 2); % precompute gamma * area(w) * log(1 / pfa) gamma_areas_log = gamma * areas * log(1 / pfa); % precompute the psr threshold for each window size psr_thresholds = zeros(nwin, 1); for i = 1:nwin psr_thresholds(i) = sqrt(gamma_areas_log(i) + 2 * gamma * areas(i)); end % create the video reader v = VideoReader(video_file); % compute the number of frames nframes = floor(v.Duration * v.FrameRate); % create the video writer if show_result vout = VideoWriter('psr_motion_detection.avi'); open(vout); end % read the first frame prev_frame = rgb2gray(readFrame(v)); % loop over each frame bbox = []; score = []; for i = 2:nframes % read the frame curr_frame = rgb2gray(readFrame(v)); % compute the difference between the frames diff_frame = imabsdiff(curr_frame, prev_frame); % perform the detection [r, c, metric] = psr_detector(diff_frame, w, pfa, gamma); % add the detections bbox = [bbox; [c(:) r(:) w(1, 2) * ones(size(r(:))) w(1, 1) * ones(size(r(:)))]]; %#ok<AGROW> score = [score; metric(:)]; %#ok<AGROW> % visualize the results if show_result imshow(curr_frame); hold on for j = 1:numel(r) rectangle('Position', [c(j) r(j) w(1, 2) w(1, 1)], 'EdgeColor', 'g'); end drawnow writeVideo(vout, getframe); hold off end % update the previous frame prev_frame = curr_frame; end % close the video writer if show_result close(vout); end end ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值