问题遇到的现象和发生背景
需要网页给我返回坐标矩阵数据
问题相关代码,请勿粘贴截图
@app.route('/set_info', methods=['POST'])
def set_info():
global new_origin_info, new_squre_w_h, new_box_h, new_box_w
request_body = json.loads(request.data)
need_change, temp_origin_info, camera_num, ship_h, ship_w, ship_l, waterline, calib_w, calib_h = check_info_need_change(
request_body)
if need_change:
new_origin_info, new_squre_w_h, new_box_h, new_box_w = temp_origin_info, calib_w, ship_l, ship_w # 更新origin
data = get_each_camera_img(new_origin_info)
return json.dumps({"code": 200, "data": data})
else:
print('更新失败')
return json.dumps({"code": 600, "data": []})
@app.route('/set_calib', methods=['POST'])
def flask_calibrate():
time_888 = time.time()
global new_origin_info, new_squre_w_h, new_box_h, new_box_w, kp_method, position_img_dict
request_body = json.loads(request.data)
camera_info = request_body['camera_info']
for info in camera_info:
serial_number, kp_ls = info['serial_number'], info['xy']
temp_position = ''
for position, value in new_origin_info.items():
if value['id'] == serial_number:
temp_position = position
new_origin_info[temp_position]['picture_keypoint'] = np.asarray(json.loads(kp_ls),
dtype=np.int).tolist()
print('初始化开始')
kp_method_new = Keypoint_Change(new_origin_info, board_h_scale, board_w_scale, new_box_h, new_box_w, new_squre_w_h)
kp_method.append(kp_method_new)
kp_method.pop(0)
print('初始化完成')
print('开始计算')
result = kp_method[0].change_img(position_img_dict)
print('计算结束:', time.time() - time_888)
return json.dumps({'code': '200', 'data': {'image': img_2_base64(result)}})
运行结果及报错内容
运行到“初始化开始”后面就报错了,显示cv2.error: OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-95hbg2jt\opencv\modules\core\src\alloc.cpp:73: error: (-4:Insufficient memory) Failed to allocate 12539160000 bytes in function 'cv::OutOfMemoryError'
我的解答思路和尝试过的方法
1.尝试增加电脑虚拟内存(无果)2.将python(32位)转为64位(无果)