Skip to content

Commit

Permalink
Some cleaning to the tests
Browse files Browse the repository at this point in the history
Use functional API to describe the graph.
  • Loading branch information
christophe0606 committed May 7, 2024
1 parent 581a08f commit a2b1664
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 104 deletions.
6 changes: 3 additions & 3 deletions Source/cannysobel.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,9 +568,9 @@ void arm_canny_edge_sobel_fixp(const arm_cv_image_q15_t* ImageIn,

void arm_canny_edge_sobel_fixp(const arm_cv_image_q15_t* ImageIn,
arm_cv_image_q15_t* ImageOut,
arm_cv_gradient_q15_t* Img_tmp_grad1/*4*/,
arm_cv_image_q15_t* Img_tmp_mag/*3*/,
arm_cv_gradient_q15_t* Img_tmp_grad2/*3*/,
arm_cv_image_gradient_q15_t* Img_tmp_grad1,
arm_cv_image_q15_t* Img_tmp_mag,
arm_cv_image_gradient_q15_t* Img_tmp_grad2,
int low_threshold,
int high_threshold)
{
Expand Down
3 changes: 2 additions & 1 deletion Testing/browser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ add_subdirectory(${CMSISDSP}/Source bin_dsp)
find_package(OpenCV)


set(NODESHEADER ${CMAKE_SOURCE_DIR}/../../stream_nodes/cpp)
set(NODESHEADER ${CMAKE_SOURCE_DIR}/../../cmsiscv_nodes/cpp)

set(CVLIBSRC ${CMAKE_SOURCE_DIR}/../../Source)

add_executable(stream)


target_sources(stream PUBLIC
stream/common.c
)
Expand Down
2 changes: 1 addition & 1 deletion Testing/browser/create_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import sys

parent_directory = os.path.abspath('../../stream_nodes')
parent_directory = os.path.abspath('../../cmsiscv_nodes')
sys.path.append(parent_directory)


Expand Down
8 changes: 4 additions & 4 deletions Testing/browser/stream/appnodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class WebDisplay(GenericSink):
def __init__(self,name,w,h,buf="dst1"):
GenericSink.__init__(self,name,identified=False)
src_t = CImageType(w,h,CImageType.RGBA)
self.addInput("i",src_t,src_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)

self.i.setBufferConstraint(name=f"{buf}",mustBeArray=True,assignedByNode=False)

Expand Down Expand Up @@ -49,7 +49,7 @@ class WebCamera(GenericSource):
def __init__(self,name,w,h):
GenericSink.__init__(self,name,identified=False)
dst_t = CImageType(w,h,CImageType.RGBA)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)
self.o.setBufferConstraint(name="src",mustBeArray=True,assignedByNode=False)


Expand All @@ -65,8 +65,8 @@ class Copy(GenericNode):
def __init__(self,name,w,h):
GenericNode.__init__(self,name,identified=False)
dst_t = CImageType(w,h,CImageType.RGBA)
self.addInput("i",dst_t,dst_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",dst_t,dst_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)


def __call__(self, i):
Expand Down
4 changes: 2 additions & 2 deletions Testing/browser/stream/opencv_nodes/canny_edge/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def __init__(self,name,w,h,firstAlgo=True,config=False):
src_t = CImageType(w,h,CImageType.GRAY8)
dst_t = CImageType(w,h,CImageType.GRAY8)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)
if not config:
self._paramBlock = 0
self.addVariableArg("nullptr")
Expand Down
4 changes: 2 additions & 2 deletions Testing/browser/stream/opencv_nodes/gaussian/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def __init__(self,name,w,h,firstAlgo=True,config=False):
src_t = CImageType(w,h,CImageType.GRAY8)
dst_t = CImageType(w,h,CImageType.GRAY8)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)
if not config:
self._paramBlock = 0
self.addVariableArg("nullptr")
Expand Down
30 changes: 0 additions & 30 deletions Testing/browser/stream/simple_graph.py

This file was deleted.

6 changes: 2 additions & 4 deletions Testing/browser/stream/tests/canny_edge/canny_edge_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ def mk_canny_edge(W=640,H=480,OPENCV=True):

gauss = gaussian(to_gray8(camera(the_graph)))

cv = canny_edge(gauss)
display1(to_rgba(canny_edge(gauss)))

display1(to_rgba(cv))

if OPENCV:
ocv = canny_edge_cv(g16_to_g8(gauss))
display2(cv_to_rgba(ocv))
display2(cv_to_rgba(canny_edge_cv(g16_to_g8(gauss))))

return(the_graph)

Expand Down
10 changes: 4 additions & 6 deletions Testing/browser/stream/tests/gaussian/gaussian_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ def mk_gaussian(W=640,H=480,OPENCV=True):
to_rgba_cv = Gray8ToRGBA("to_rgba_cv",W,H)
display2=WebDisplay2("display2",W,H)

gray = to_gray8(camera(the_graph))
gauss = gaussian(gray)
display1(to_rgba(gauss))

gray=(to_gray8(camera(the_graph)))
display1(to_rgba(gaussian(gray)))

if OPENCV:
gausscv = gaussianCV(gray)
display2(to_rgba_cv(gausscv))
display2(to_rgba_cv(gaussianCV(gray)))

return(the_graph)

Expand Down
6 changes: 2 additions & 4 deletions Testing/browser/stream/tests/template/template_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ def mk_template(W=640,H=480,OPENCV=True):
display2=WebDisplay2("display2",W,H)

gray = to_gray8(camera(the_graph))
gauss = gaussian(gray)
display1(to_rgba(gauss))
display1(to_rgba(gaussian(gray)))

if OPENCV:
gausscv = gaussianCV(gray)
display2(to_rgba_cv(gausscv))
display2(to_rgba_cv(gaussianCV(gray)))

return(the_graph)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.YUV)
dst_t = CImageType(w,h,CImageType.RGB)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -31,8 +31,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.YUV)
dst_t = CImageType(w,h,CImageType.GRAY16)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -52,8 +52,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.YUV)
dst_t = CImageType(w,h,CImageType.GRAY8)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -74,8 +74,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.GRAY16)
dst_t = CImageType(w,h,CImageType.RGB)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -95,8 +95,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.GRAY8)
dst_t = CImageType(w,h,CImageType.RGB)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -116,8 +116,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.GRAY8)
dst_t = CImageType(w,h,CImageType.GRAY16)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -137,8 +137,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.GRAY16)
dst_t = CImageType(w,h,CImageType.GRAY8)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -158,8 +158,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.GRAY8)
dst_t = CImageType(w,h,CImageType.RGBA)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -179,8 +179,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.GRAY16)
dst_t = CImageType(w,h,CImageType.RGBA)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -200,8 +200,8 @@ def __init__(self,name,w,h):
src_t = CImageType(w,h,CImageType.RGBA)
dst_t = CImageType(w,h,CImageType.GRAY8)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ def __init__(self,name,w,h,firstAlgo=True,config=False):
src_t = CImageType(w,h,CImageType.GRAY16)
dst_t = CImageType(w,h,CImageType.GRAY16)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)
if not config:
self._paramBlock = 0
self.addVariableArg("nullptr")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@ def __init__(self,name,w,h,firstAlgo=True,config=False):
src_t = CImageType(w,h,CImageType.GRAY8)
dst_t = CImageType(w,h,CImageType.GRAY16)

self.addInput("i",src_t,src_t._nb_bytes)
self.addOutput("o",dst_t,dst_t._nb_bytes)

if not config:
self._paramBlock = 0
else:
if firstAlgo:
self._paramBlock = 1
else:
self._paramBlock = 2
self.addInput("i",src_t,src_t.nb_bytes)
self.addOutput("o",dst_t,dst_t.nb_bytes)

def __call__(self, i):
g,n = i
Expand All @@ -33,11 +25,3 @@ def __call__(self, i):
def typeName(self):
"""The name of the C++ class implementing this node"""
return "GaussianFilter"

@property
def paramBlock(self):
return self._paramBlock

@property
def params(self):
return {"name":"CMSIS-CV Gaussian Filter"}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class CImageType(CGStaticType):
GRAY16 = 3
GRAY8 = 4
RGBA = 5
Q15 = 6
GRADIENT_Q15 = 7

def __init__(self,w,h,t=YUV):
CGStaticType.__init__(self)
Expand Down Expand Up @@ -56,21 +58,28 @@ def format(self):
def bytes(self):
# The C code is using array of int8
# This type is just used at Python / Graphviz level
# because in input / output creations in the node we give
# the number of bytes.
# So the sample size is 1 byte
# Having int8 FIFOs is more flexible since we can
# do some casting without having to introduce casting nodes in the
# graph. But then it means compatibility check between IOs
# when no casting possible must be done at the Python level.
return 1
#if self._pixel_type == CImageType.YUV:
# return(int(1.5*self._w*self._h))
#if self._pixel_type == CImageType.RGB:
# return(int(3*self._w*self._h))
#


@property
def _nb_bytes(self):
def nb_bytes(self):
if self._pixel_type == CImageType.YUV:
return(int(1.5*self._w*self._h))
if self._pixel_type == CImageType.RGB:
return(int(3*self._w*self._h))
if self._pixel_type == CImageType.GRAY16:
return(int(2*self._w*self._h))
if self._pixel_type == CImageType.Q15:
return(int(2*self._w*self._h))
if self._pixel_type == CImageType.GRADIENT_Q15:
return(int(4*self._w*self._h))
if self._pixel_type == CImageType.GRAY8:
return(int(self._w*self._h))
if self._pixel_type == CImageType.RGBA:
Expand All @@ -85,9 +94,13 @@ def graphViztype(self):
if self.format == CImageType.YUV:
return(escape(f"YUV_{self.width}_{self.height}"))
if self.format == CImageType.RGB:
return(escape(f"RGB_{self.width}_{self.height}"))
return(escape(f"RGB888_{self.width}_{self.height}"))
if self.format == CImageType.GRAY16:
return(escape(f"GRAY16_{self.width}_{self.height}"))
if self.format == CImageType.Q15:
return(escape(f"Q15_{self.width}_{self.height}"))
if self.format == CImageType.GRADIENT_Q15:
return(escape(f"GRAD_Q15_{self.width}_{self.height}"))
if self.format == CImageType.GRAY8:
return(escape(f"GRAY8_{self.width}_{self.height}"))
if self.format == CImageType.RGBA:
Expand Down

0 comments on commit a2b1664

Please sign in to comment.