Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jk_edge_code_api_integration
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikhin.vc
jk_edge_code_api_integration
Commits
91074b9a
Commit
91074b9a
authored
May 05, 2023
by
Sikhin VC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added server API endpoints
parent
c673cc3f
Pipeline
#69235
canceled with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
30 deletions
+7
-30
Dockerfile
Dockerfile
+0
-1
app.py
app.py
+0
-2
edge_engine/common/config.py
edge_engine/common/config.py
+3
-4
scripts/cement_counter.py
scripts/cement_counter.py
+4
-23
No files found.
Dockerfile
View file @
91074b9a
FROM
jk:v1
RUN
pip
install
loguru
ADD
. /app
WORKDIR
/app
...
...
app.py
View file @
91074b9a
import
os
# os.environ["config"]="{\"deployment ID\": \"jkv1_dba3e4e8\"}"
from
edge_engine.edge_processor
import
ExecutePipeline
from
edge_engine.edge_processor
import
Pubs
from
scripts
import
CementBagCounter
...
...
edge_engine/common/config.py
View file @
91074b9a
...
...
@@ -4,7 +4,7 @@ from dateutil import parser
from
datetime
import
datetime
import
json
import
requests
from
loguru
import
logger
def
licence_validator
(
payload
):
try
:
...
...
@@ -29,7 +29,7 @@ BASE_LOG_PATH = os.environ.get('BASE_LOG_PATH',
if
not
os
.
path
.
isdir
(
BASE_LOG_PATH
):
os
.
mkdir
(
BASE_LOG_PATH
)
CONFIG_ENV
=
json
.
loads
(
os
.
environ
.
get
(
'config'
,
default
=
None
))
CONFIG_ENV
=
json
.
loads
(
os
.
environ
.
get
(
'config'
,
default
=
None
))
DEPLOYMENT_ID
=
CONFIG_ENV
.
get
(
'DEPLOYMENT_ID'
,
None
)
GET_JANUS_DETAILS
=
CONFIG_ENV
.
get
(
'GET_JANUS_DETAILS'
,
None
)
MONGO_URI_ADD_EVENTLOGS
=
CONFIG_ENV
.
get
(
'MONGO_URI'
,
None
)
...
...
@@ -38,8 +38,7 @@ EDGE_CONFIG = requests.get(url).json()["data"]
LAST_COUNT
=
requests
.
get
(
url
)
.
json
()[
"latest_count"
]
if
not
LAST_COUNT
:
LAST_COUNT
=
0
logger
.
info
(
f
"RESPONSE {requests.get(url).json()}"
)
DEVICE_ID
=
EDGE_CONFIG
[
"deviceId"
]
DEVICE_ID
=
EDGE_CONFIG
[
"deviceId"
]
DATA_PATH
=
EDGE_CONFIG
[
"inputConf"
]
.
get
(
'dataPath'
,
os
.
path
.
join
(
os
.
getcwd
(),
"data"
.
format
()))
sys
.
stderr
.
write
(
"Loading data from {}
\n
"
.
format
(
DATA_PATH
))
\ No newline at end of file
scripts/cement_counter.py
View file @
91074b9a
import
base64
from
datetime
import
datetime
import
time
from
collections
import
deque
from
uuid
import
uuid4
import
cv2
import
numpy
as
np
from
edge_engine.ai.model.modelwraper
import
ModelWrapper
from
edge_engine.common.logsetup
import
logger
from
expiringdict
import
ExpiringDict
from
scripts.common.config
import
MONGO_URI
from
scripts.common.constants
import
JanusDeploymentConstants
from
scripts.utils.centroidtracker
import
CentroidTracker
# from scripts.utils.edge_utils import get_extra_fields
from
scripts.utils.helpers
import
box_iou2
from
scripts.utils.image_utils
import
draw_circles_on_frame
,
resize_to_64_64
from
scripts.utils.infocenter
import
MongoLogger
from
scripts.utils.image_utils
import
draw_circles_on_frame
from
scripts.utils.tracker
import
Tracker
from
scripts.utils.yolov5_trt
import
YoloV5TRT
from
scipy.optimize
import
linear_sum_assignment
as
linear_assignment
...
...
@@ -332,9 +326,7 @@ class CementBagCounter(ModelWrapper):
img2
=
cv2
.
resize
(
img2
,
(
64
,
64
))
bs64
=
str
(
base64
.
b64encode
(
img2
)
.
decode
(
'utf-8'
))
# Changed this line. converted byte to string
json
=
{
"eventId"
:
str
(
uuid1
())
.
split
(
'-'
)[
0
],
"cameraId"
:
EDGE_CONFIG
[
'deviceId'
],
"cameraName"
:
EDGE_CONFIG
[
'deviceId'
],
"timestamp"
:
datetime
.
isoformat
(
datetime
.
now
()),
"frame"
:
bs64
,
"cement_bag_count"
:
str
(
self
.
count
)}
logger
.
info
(
f
"json is {json}"
)
response
=
requests
.
post
(
url
=
MONGO_URI_ADD_EVENTLOGS
,
json
=
json
)
logger
.
info
(
f
"response is : {response.text}"
)
requests
.
post
(
url
=
MONGO_URI_ADD_EVENTLOGS
,
json
=
json
)
logger
.
info
(
f
"Count: {self.count}"
)
frame
=
draw_circles_on_frame
(
frame
,
centroid
,
radius
=
10
,
color
=
(
0
,
255
,
0
),
thickness
=-
1
...
...
@@ -437,12 +429,13 @@ class CementBagCounter(ModelWrapper):
in
zip
(
result_boxes
,
result_scores
,
result_classid
)]
# TRT Additions stop
#adding logic to avoid double detections
class_name
=
list
()
bboxs
=
[]
if
dets
:
# adding logic to avoid double detections
dets
,
frame
=
self
.
overlapping_removal
(
frame
,
dets
)
for
i
in
dets
:
class_name
.
append
(
i
[
"class"
])
...
...
@@ -452,18 +445,6 @@ class CementBagCounter(ModelWrapper):
return
bboxs
,
frame
,
dets
,
class_name
# def _analyse_image(self, frame):
# try:
#
# dets, frame, _dets, class_name = self.inference(frame)
# frame, objects, boxs = self.kalman_tracker(dets, frame)
# frame = self.update_bag_count(frame=frame, detection_objects=objects, class_name=class_name,
# detections=_dets)
# logger.debug("self.uncounted_objects --> {}".format(self.uncounted_objects))
#
# except Exception as e:
# logger.exception(f"Error: {e}", exc_info=True)
def
_predict
(
self
,
obj
):
try
:
frame
=
obj
[
'frame'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment