当前位置: 首页 > news >正文

做代购网站如何缴税河北网络推广技术

做代购网站如何缴税,河北网络推广技术,亚马逊网网站建设规划报告,挂机软件定制本文介绍两种方法 1、经纬度矫正法 2、棋盘格矫正法 一、经纬度矫正法 1、算法说明 经纬度矫正法, 可以把鱼眼图想象成半个地球, 然后将地球展开成地图,经纬度矫正法主要是利用几何原理, 对图像进行展开矫正。 经过P点的入射光线…

本文介绍两种方法

1、经纬度矫正法

2、棋盘格矫正法

一、经纬度矫正法

1、算法说明

经纬度矫正法, 可以把鱼眼图想象成半个地球, 然后将地球展开成地图,经纬度矫正法主要是利用几何原理, 对图像进行展开矫正。

        经过P点的入射光线没有透镜的话,本应交于相机成像平面的e点。然而,经过鱼眼相机的折射,光线会交于相机成像平面的d点,就产生了畸变,因此畸变图像整体上呈现出像素朝图像中心点聚集的态势。

        而去畸变,就是将折射到d点的点,重新映射回到e点,因此去畸变之后的图像与原始的鱼眼图像相比,仿佛是把向心聚集的像素又重新向四周铺展开来。

       详细的推导流程及公式见地址:AVM环视系统——鱼眼相机去畸变算法 - 知乎

2、 代码

import math
from PIL import Imageim = Image.open("/Users/Fisheye_photo-600x600.jpg")
im.show()width, high = im.size
sqrt_len = min(width, high)
im = im.transform((sqrt_len, sqrt_len),Image.EXTENT,((width-sqrt_len)/2, (high-sqrt_len)/2, sqrt_len+(width-sqrt_len)/2, sqrt_len+(high-sqrt_len)/2))
width = high = sqrt_lenidata = im.getdata()
odata = []alpha = math.pi/2out_high = round(high * math.tan(alpha/2))
out_width = round(width * math.tan(alpha/2))
out_radius = round(high * math.tan(alpha/2))
out_center_x = out_width / 2
out_center_y = out_high / 2out_bl_x = 0
out_br_x = out_width - 1
out_bt_y = 0
out_bb_y = out_high - 1out_bl_cx = out_bl_x - out_center_x
out_br_cx = out_br_x - out_center_x
out_bt_cy = out_bt_y - out_center_y
out_bb_cy = out_bb_y - out_center_ysrc_radius = round(high * math.sin(alpha/2))
src_center_x = width / 2
src_center_y = high / 2for i in range(0, high * width):ox = math.floor(i / out_width)oy = i % out_highcx = ox - out_center_x;cy = oy - out_center_y;out_distance = round(math.sqrt(pow(cx, 2) + pow(cy, 2)))theta = math.atan2(cy, cx)if (-math.pi/4 <= theta <= math.pi/4):bx = out_radius * math.cos(math.pi/4)by = bx * math.tan(theta)elif (math.pi/4 <= theta <= math.pi*3/4):by = out_radius * math.sin(math.pi/4)bx = by / math.tan(theta)elif (-math.pi*3/4 <= theta <= -math.pi/4):by = out_radius * math.sin(-math.pi/4)bx = by / math.tan(theta)else:bx = out_radius * math.cos(-math.pi*3/4)by = bx * math.tan(theta)bdy_distance = round(math.sqrt(pow(cx, 2) + pow(cy, 2)))src_distance = src_radius * bdy_distance / out_radiussrc_x = round(src_center_x + math.cos(theta) * src_distance)src_y = round(src_center_y + math.sin(theta) * src_distance)src_idx = src_x*width + src_y    if(0 < src_idx < high*width):odata.append(idata[src_idx])else:odata.append((0,0,0))om = Image.new("RGB", (high, width))
om.putdata(odata)
om.show()

3、代码及图片地址:GitHub - duducosmos/defisheye: Fast Corrects for fisheye distortion in an image.

二、棋盘格矫正方法

1、算法说明

利用棋盘格进行标定, 然后计算鱼眼镜头的畸变系数以及内参, opencv中自带有fisheye模块, 可以直接根据棋盘格标定结果,采用cv2.fisheye.calibrate计算畸变系数以及内参, 然后使用cv2.fisheye.initUndistortRectifyMap函数计算映射矩阵, 最后根据映射矩阵, 使用cv2.remap进行矫正。

2、代码

import cv2
import numpy as np
import math
import time# 鱼眼有效区域截取
def cut(img):img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)(_, thresh) = cv2.threshold(img_gray, 20, 255, cv2.THRESH_BINARY)contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)cnts = sorted(contours, key=cv2.contourArea, reverse=True)[0]x,y,w,h = cv2.boundingRect(cnts)r = max(w/ 2, h/ 2)# 提取有效区域img_valid = img[y:y+h, x:x+w]return img_valid, int(r)# 鱼眼矫正
def undistort(src,r):# r: 半径, R: 直径R = 2*r# Pi: 圆周率Pi = np.pi# 存储映射结果dst = np.zeros((R, R, 3))src_h, src_w, _ = src.shape# 圆心x0, y0 = src_w//2, src_h//2for dst_y in range(0, R):theta =  Pi - (Pi/R)*dst_ytemp_theta = math.tan(theta)**2for dst_x in range(0, R):# 取坐标点 p[i][j]# 计算 sita 和 fiphi = Pi - (Pi/R)*dst_xtemp_phi = math.tan(phi)**2tempu = r/(temp_phi+ 1 + temp_phi/temp_theta)**0.5tempv = r/(temp_theta + 1 + temp_theta/temp_phi)**0.5if (phi < Pi/2):u = x0 + tempuelse:u = x0 - tempuif (theta < Pi/2):v = y0 + tempvelse:v = y0 - tempvif (u>=0 and v>=0 and u+0.5<src_w and v+0.5<src_h):dst[dst_y, dst_x, :] = src[int(v+0.5)][int(u+0.5)]# 计算在源图上四个近邻点的位置# src_x, src_y = u, v# src_x_0 = int(src_x)# src_y_0 = int(src_y)# src_x_1 = min(src_x_0 + 1, src_w - 1)# src_y_1 = min(src_y_0 + 1, src_h - 1)## value0 = (src_x_1 - src_x) * src[src_y_0, src_x_0, :] + (src_x - src_x_0) * src[src_y_0, src_x_1, :]# value1 = (src_x_1 - src_x) * src[src_y_1, src_x_0, :] + (src_x - src_x_0) * src[src_y_1, src_x_1, :]# dst[dst_y, dst_x, :] = ((src_y_1 - src_y) * value0 + (src_y - src_y_0) * value1 + 0.5).astype('uint8')return dstif __name__ == "__main__":t = time.perf_counter()frame = cv2.imread('../imgs/pig.jpg')cut_img,R = cut(frame)result_img = undistort(cut_img,R)cv2.imwrite('../imgs/pig_nearest.jpg',result_img)print(time.perf_counter()-t)

效果图

3、代码地址

https://github.com/HLearning/fisheye

三、总结:比对两个算法

本人用两个算法对一张图像进行拉直,发现经过经纬度矫正算法生成的图像原作者裁剪掉了边缘部分,见下图效果图,中间黑框内的图像是经过“经纬度矫正法”得到的效果图,外面的大图是用“棋盘格矫正法”得到的效果图

为了更直观,更改了图像的透明度,可以看出两个算法的效果还是多少有些差别的。

其实,两个算法的边缘部分都被严重拉伸,丢不丢掉看适用场景和个人需要吧。

四、知识拓展

立体标定

算法说明

坐标映射建立,各区域的角点都有一维世界坐标为0,对应图5中三幅子图像分别为Y=0,X=0,Z=0。根据棋盘方格边长以及与世界坐标原点间隔的方格数,可得到所有角点的世界坐标。从而建立起二维图像坐标与三维世界坐标的一一映射,用于模型参数的求解。

 

参考地址:采用立体标定板的鱼眼相机快速标定方法_真空技术_新闻动态_深圳市鼎达信装备有限公司

基于双经度模型的鱼眼图像畸变矫正方法

基于双经度模型的鱼眼图像畸变矫正方法 - 百度文库

 

http://www.dinnco.com/news/63312.html

相关文章:

  • 网站域名查询系统wxbwxbwxb成品人和精品人的区别在哪
  • 潮州网站开发seo研究协会网app
  • 南宁高端网站建设公司百度账号免费注册
  • 网站asp设计作品广州新闻发布
  • b2c网站好处竞价推广账户托管费用
  • 那个网站点击率高网络推广方案的内容
  • 网站建设需求表格网络运营师
  • 猫咪官网18点击进入湖南企业竞价优化服务
  • 有代码怎么做网站网络营销的四种形式
  • 网站建设咨询电话手机推广软文
  • 石家庄营销型网站建设公司微平台推广
  • 容桂网站建设哪家公司好惠州百度seo地址
  • 佛山网站建设科技公司信息流优化师工作内容
  • 壹像素网站seo优化多少钱
  • 建设小程序怎么挂失抚顺seo
  • 河北省建设机械协会网站是真的吗网络培训班
  • 怎么做自己网站的后台搜索引擎营销的特点是
  • 淘宝网站推广推广引流
  • 镜像网站能否做google排名网站推广的常用方法
  • 旅游网站开发目的和意义百度竞价推广的技巧
  • 做暧暖免费观看网站种子搜索神器
  • 做网站app怎么赚钱成都网站seo推广
  • 免费的行情网站下载安装百度怎么进入官方网站
  • 做直播网站用什么系统网站整站优化推广方案
  • 少主网络建站站内优化怎么做
  • 优秀ppt案例欣赏seo是什么意思网络用语
  • 网站如何做才能被360收录网站优化seo培训
  • 网站什么内容常用的网络营销平台有哪些
  • cpa推广app赚钱联盟平台网站外链的优化方法
  • 泉州网站建设价钱济南seo网络优化公司