I am the first time to build 4.0.0-pre, but I did not feel particularly late.
In Xavier, the speed was quite different depending on TBB ON/OFF(-D WITH_TBB=ON) at 3.4 build.
So it is a difference in build options.
opencv-3.3.1(JetPack4.1): cv2_Canny(): 0.26661168300779536
opencv-3.4.1(build from source): cv2_Canny(): 0.2553883320069872
opencv-4.4.0-pre(build from source): cv2_Canny(): 0.3225515089870896
opencv-4.4.0-pre(build from source with your option): cv2_Canny(): 2.381617232997087
Test code:
import timeit
import sys
import cv2
print("opencv - {}".format(cv2.__version__))
print("Python - {}".format(sys.version))
N = 100
print("N = {}".format(N))
cap = cv2.VideoCapture(0)
width=1280
height=720
edgeThreshold = 40
cap.set(cv2.CAP_PROP_FRAME_WIDTH, width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, height)
if not cap.isOpened():
# camera failed
raise IOError(("Couldn't open video file or webcam."))
ret_val, frame = cap.read()
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(hsv, (7, 7), 1.5 )
def cv2_read():
ret_val, frame = cap.read()
def cv2_resize():
f = cv2.resize(frame, (640, 360))
def cv2_toGray():
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
def cv2_GaussianBlur():
blur = cv2.GaussianBlur(hsv, (7, 7), 1.5 )
def cv2_Canny():
edges = cv2.Canny(blur, 0, edgeThreshold)
if __name__ == "__main__":
t = timeit.timeit(setup="from __main__ import cv2_read", stmt='cv2_read()', number=N)
print("cv2_read(): {}".format(t))
t = timeit.timeit(setup="from __main__ import cv2_resize", stmt='cv2_resize()', number=N)
print("cv2_resize(): {}".format(t))
t = timeit.timeit(setup="from __main__ import cv2_toGray", stmt='cv2_toGray()', number=N)
print("cv2_toGray(): {}".format(t))
t = timeit.timeit(setup="from __main__ import cv2_GaussianBlur", stmt='cv2_GaussianBlur()', number=N)
print("cv2_GaussianBlur(): {}".format(t))
t = timeit.timeit(setup="from __main__ import cv2_Canny", stmt='cv2_Canny()', number=N)
print("cv2_Canny(): {}".format(t))
Result: opnecv-3.3.1 (JetPack4.1)
opencv - 3.3.1
Python - 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
N = 100
cv2_read(): 13.39863662699645
cv2_resize(): 0.038163264995091595
cv2_toGray(): 0.025768125997274183
cv2_GaussianBlur(): 0.5404331860045204
cv2_Canny(): 0.26661168300779536
Result: opencv-3.4.1 (build from source)
opencv - 3.4.1
Python - 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
N = 100
nvbuf_utils: Could not get EGL display connection
nvbuf_utils: Could not get EGL display connection
nvbuf_utils: Could not get EGL display connection
nvbuf_utils: Could not get EGL display connection
cv2_read(): 3.3356981789984275
cv2_resize(): 0.03994057800446171
cv2_toGray(): 0.02382903700345196
cv2_GaussianBlur(): 0.14375564000511076
cv2_Canny(): 0.2553883320069872
Result: opencv-4.0.0-pre (build from source)
opencv - 4.0.0-pre
Python - 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
N = 100
cv2_read(): 14.22163662899402
cv2_resize(): 0.043780744992545806
cv2_toGray(): 0.02563618701242376
cv2_GaussianBlur(): 0.11342920899915043
cv2_Canny(): 0.3225515089870896
Result: opencv-4.0.0-pre (build from source with your option)
opencv - 4.0.0-pre
Python - 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]
N = 1000
cv2_resize(): 0.36299609699926805
cv2_toGray(): 0.16359981399727985
cv2_GaussianBlur(): 0.6509453210019274
cv2_Canny(): 2.381617232997087