小编Zee*_*han的帖子

opencv error:输入参数的大小不匹配

我正在使用金字塔进行图像混合... m得到一个opencv错误..我正在关注官方opencv教程. http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_tutorials.html

import cv2
import numpy as np,sys

A = cv2.imread('/home/grayhat/apple.jpg')
B = cv2.imread('/home/grayhat/orange.jpg')

# generate Gaussian pyramid for A
G = A.copy()
gpA = [G]
for i in xrange(6):
    G = cv2.pyrDown(G)
    gpA.append(G)

# generate Gaussian pyramid for B
G = B.copy()
gpB = [G]
for i in xrange(6):
    G = cv2.pyrDown(G)
    gpB.append(G)

# generate Laplacian Pyramid for A
lpA = [gpA[5]]
for i in xrange(5,0,-1):
   GE = cv2.pyrUp(gpA[i])
   L = cv2.subtract(gpA[i-1],GE)
   lpA.append(L)

# generate Laplacian Pyramid for …
Run Code Online (Sandbox Code Playgroud)

python opencv numpy matplotlib

4
推荐指数
1
解决办法
6186
查看次数

django restframework:获取 NotImplementedError

我收到 NotimplementError。我正在研究 Django restframework 身份验证和权限。我可以通过管理面板输入数据,但是当涉及到序列化程序时,我收到了这个错误。

下面是错误报告:

NotImplementedError at /api/tasks/

Field.to_representation() must be implemented for field owner. If you do not need to support write operations you probably want to subclass `ReadOnlyField` instead.

Request Method:     GET
Request URL:    http://127.0.0.1:8000/api/tasks/
Django Version:     1.9
Exception Type:     NotImplementedError
Exception Value:    

Field.to_representation() must be implemented for field owner. If you do not need to support write operations you probably want to subclass `ReadOnlyField` instead.

Exception Location:     /home/graymatter/test/bookenv/local/lib/python2.7/site-packages/rest_framework/fields.py in to_representation, line 529
Python Executable:  /home/graymatter/test/bookenv/bin/python
Python …
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework

4
推荐指数
2
解决办法
7677
查看次数

权限:在 Django 休息框架中

我正在研究 django rest 框架。我在权限方面遇到问题。我想向管理员用户授予 G​​ET 和 POST 权限,而仅向其他用户授予 POST 权限(真实)。到目前为止,我已经编写了以下代码:

权限.py

class UserAccessPermission(permissions.BasePermission):
    def has_permission(self, request, view):
        if request.method == 'GET' or request.method == 'POST':
            return request.user and request.user.is_staff
        if request.method == 'POST':
            return request.user and request.user.is_authenticated()
Run Code Online (Sandbox Code Playgroud)

此代码未按预期工作。只有管​​理员用户才能 GET 和 POST。其他用户没有获得任何许可。

伙计们帮忙。提前致谢。

已编辑

class UserAccessPermission(permissions.BasePermission):
    def has_permission(self, request, view):
        if request.method == 'POST':
            return request.user and request.user.is_authenticated()
        elif request.method == 'GET':
            return request.user and request.user.is_staff
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework

3
推荐指数
1
解决办法
513
查看次数