diff --git a/app/resources/collection/blocks/Blocks/OpenCV/ObjectDetector.vc b/app/resources/collection/blocks/Blocks/OpenCV/ObjectDetector.vc new file mode 100644 index 00000000..e01044b0 --- /dev/null +++ b/app/resources/collection/blocks/Blocks/OpenCV/ObjectDetector.vc @@ -0,0 +1,139 @@ +{ + "version": "1.0", + "package": { + "name": "ObjectDetector", + "version": "1.0.0", + "description": "Performs Object Detection on Image", + "author": "Faizan Ahmed", + "image": "" + }, + "design": { + "board": "Python3-Noetic", + "graph": { + "blocks": [ + + { + "id": "100", + "type": "basic.input", + "data": { + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true + }, + "position": { + "x": 64, + "y": 144 + } + }, + + { + "id": "200", + "type": "basic.output", + "data": { + "name": "", + "pins": [ + { + "index": "0", + "name": "", + "value": "0" + } + ], + "virtual": true + }, + "position": { + "x": 752, + "y": 144 + } + }, + + { + "id": "300", + "type": "basic.code", + "data": { + "code": "# import required packages\nimport cv2\nimport argparse\nimport numpy as np\nfrom time import sleep\nfrom wires.wire_img import Wire_Read, Wire_Write\n\nclassName = []\n#Target Classes name\nclassesFile = 'backend/modules/yolov3.txt'\n\nwith open(classesFile,'rt') as f:\n className = f.read().rstrip('\\n').split('\\n')\n\ndef findObjects(outputs, img):\n confThreshold = 0.5\n nmsThreshold = 0.3\n hT, wT, cT = img.shape\n bbox = []\n classIds = []\n confs = []\n\n for output in outputs:\n for det in output:\n scores = det[5:]\n classId = np.argmax(scores)\n confidence = scores[classId]\n if confidence > confThreshold:\n #get height and weight of box\n w,h = int(det[2] * wT), int(det[3] * hT)\n #as det[0] and det[1] are x,y of center of box so these are converted to starting\n #x and y\n x,y = int((det[0]*wT) - w/2), int((det[1]*hT) - h/2)\n bbox.append([x,y,w,h])\n classIds.append(classId)\n confs.append(float(confidence))\n #print(len(bbox))\n \n indices = cv2.dnn.NMSBoxes(bbox, confs, confThreshold, nmsThreshold)\n for i in indices:\n i = i[0]\n box = bbox[i]\n x,y,w,h = box[0],box[1],box[2],box[3]\n cv2.rectangle(img,(x,y),(x+w, y+h),(255,0,255),2)\n #print(len(className))\n cv2.putText(img,f'{className[classIds[i]].upper()} {int(confs[i]*100)}%',\n (x,y-10),cv2.FONT_HERSHEY_SIMPLEX, 0.6, (255,0,255),2)\n \ndef ObjectDetector( input_wires, output_wires, parameters ):\n shm_r = Wire_Read(input_wires[0])\n shm_w = Wire_Write(output_wires[0]) \n #loading video cam\n \n #width and height of Target Frame\n whT = 320\n #confidence threshold \n \n #lower it is more aggrestive it will\n \n\n \n \n \n print(\"className:\", className)\n \n #print(len(className))\n modelConfiguration = 'backend/modules/yolov3.cfg'\n modelWeights = 'backend/modules/yolov3.weights'\n\n #loading YOLO Model from Darknet\n net = cv2.dnn.readNetFromDarknet(modelConfiguration,modelWeights)\n net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)\n net.setPreferableTarget(cv2.dnn. DNN_TARGET_CPU)\n\n\n\n \n while True:\n img = shm_r.get()\n #converting img to blob\n blob = cv2.dnn.blobFromImage(img, 1/255,(whT,whT),[0,0,0],1, crop = False)\n\n #Passing blob to network\n net.setInput(blob)\n\n #geting Layers Name\n layerNames = net.getLayerNames()\n #print(layerNames)\n #print(net.getUnconnectedOutLayers())\n outputNames = [layerNames[i[0]-1] for i in net.getUnconnectedOutLayers()]\n #print(outputNames)\n\n #forward Pass\n outputs = net.forward(outputNames)\n #print(outputs[0].shape)\n #print(outputs[1].shape)\n #print(outputs[2].shape)\n\n findObjects(outputs,img) \n shm_w.add(img)\n ", + "params": [], + "ports": { + "in": [ + { + "name": "100" + } + ], + "out": [ + { + "name": "200" + } + ] + } + }, + "position": { + "x": 248, + "y": 88 + }, + "size": { + "width": 384, + "height": 256 + } + }, + + { + "id": "400", + "type": "basic.constant", + "data": { + "name": "Lower Thresh", + "value": "85", + "local": true + }, + "position": { + "x": 328, + "y": 10 + } + }, + { + "id": "401", + "type": "basic.constant", + "data": { + "name": "Upper Thresh", + "value": "255", + "local": true + }, + "position": { + "x": 428, + "y": 10 + } + } + + ], + + "wires": [ + { + "source": { + "block": "", + "port": "" + }, + "target": { + "block": "", + "port": "" + } + }, + + { + "source": { + "block": "", + "port": "" + }, + "target": { + "block": "", + "port": "" + } + } + ] + } + }, + "dependencies": {} +} diff --git a/docs/_pages/documentation.md b/docs/_pages/documentation.md index 371ed24b..d6ec1ad2 100755 --- a/docs/_pages/documentation.md +++ b/docs/_pages/documentation.md @@ -143,6 +143,15 @@ Extension: .vc - Output: BGR Image with Detections. - Parameters: Bounding Box Info ('box') / Image with Detections ('image') +### Object Detector + +![alt_text]({{ "assets/images/icons/objectDetector.png" | absolute_url }}) + +- Description: Detects objects in an Image using YOLOv3. +- Input: BGR Image +- Output: BGR Image with Detections. +- Parameters: Bounding Box Info ('box') / Image with Detections ('image') + ### Image Read ![alt_text]({{ "assets/images/icons/imageread.png" | absolute_url }}) diff --git a/docs/_pages/install.md b/docs/_pages/usermanual.md similarity index 54% rename from docs/_pages/install.md rename to docs/_pages/usermanual.md index a4969de4..1b2bb2db 100755 --- a/docs/_pages/install.md +++ b/docs/_pages/usermanual.md @@ -1,7 +1,7 @@ --- permalink: /install/ -title: "Installation" +title: "User Manual" sidebar: nav: "docs" @@ -99,6 +99,61 @@ cd visualcircuit npm start ``` +#### Well Done! you have Successfully Installed the VisualCircuit + +![alt_text]({{ "assets/images/Vc.png" | absolute_url }}) + + +Now it's time to play with it. + +## Build first application: + +We are now going to create our first running robotics application using Visual Circuit. + +First of all, on the top right corner you will find some options like Basic, Block, and etc. + +![alt_text]({{ "assets/images/right top.png" | absolute_url }}) + +Click on the Blocks and following menu will be poped up. + +![alt_text]({{ "assets/images/blocks.png" | absolute_url }}) + +Expand the openCV. + +![alt_text]({{ "assets/images/openCV.png" | absolute_url }}) + + + +Select the camera and place it. + + +![alt_text]({{ "assets/images/camera.png" | absolute_url }}) + +Again go to openCV. This time select the screen and place it. + +![alt_text]({{ "assets/images/screen.png" | absolute_url }}) + +Now connect the camera to screen. click and hold on the out going edge of camera and join it to the in comming edge of screen. +![alt_text]({{ "assets/gif/connection.gif" | absolute_url }}) + +#### Your application has been setted up. It's time to execute your first application. +To do so, first saved your application by pressing ctrl+s. It will ask you to name your application. + +![alt_text]({{ "assets/images/saving.png" | absolute_url }}) + +After doing that click on the files from the top left corner and following menu will be poped up. + +![alt_text]({{ "assets/images/left top.png" | absolute_url }}) + +Go to build and press Python-ROS-Neotic +![alt_text]({{ "assets/images/running app.png" | absolute_url }}) + +#### Here you go your application is setted up. Congratulations buddy. + + + + + diff --git a/docs/assets/gif/README.md b/docs/assets/gif/README.md new file mode 100644 index 00000000..62c3209d --- /dev/null +++ b/docs/assets/gif/README.md @@ -0,0 +1 @@ +All GIFs here. diff --git a/docs/assets/gif/connection.gif b/docs/assets/gif/connection.gif new file mode 100644 index 00000000..24f53fc9 Binary files /dev/null and b/docs/assets/gif/connection.gif differ diff --git a/docs/assets/images/Vc.png b/docs/assets/images/Vc.png new file mode 100644 index 00000000..bcb9ebdf Binary files /dev/null and b/docs/assets/images/Vc.png differ diff --git a/docs/assets/images/blocks.png b/docs/assets/images/blocks.png new file mode 100644 index 00000000..a1a3302f Binary files /dev/null and b/docs/assets/images/blocks.png differ diff --git a/docs/assets/images/camera.png b/docs/assets/images/camera.png new file mode 100644 index 00000000..f56c54c3 Binary files /dev/null and b/docs/assets/images/camera.png differ diff --git a/docs/assets/images/connection.png b/docs/assets/images/connection.png new file mode 100644 index 00000000..538e60ff Binary files /dev/null and b/docs/assets/images/connection.png differ diff --git a/docs/assets/images/file.png b/docs/assets/images/file.png new file mode 100644 index 00000000..09ade028 Binary files /dev/null and b/docs/assets/images/file.png differ diff --git a/docs/assets/images/icons/objectDetector.png b/docs/assets/images/icons/objectDetector.png new file mode 100644 index 00000000..b1640dd9 Binary files /dev/null and b/docs/assets/images/icons/objectDetector.png differ diff --git a/docs/assets/images/left top.png b/docs/assets/images/left top.png new file mode 100644 index 00000000..144c3376 Binary files /dev/null and b/docs/assets/images/left top.png differ diff --git a/docs/assets/images/openCV.png b/docs/assets/images/openCV.png new file mode 100644 index 00000000..68a933a0 Binary files /dev/null and b/docs/assets/images/openCV.png differ diff --git a/docs/assets/images/right top.png b/docs/assets/images/right top.png new file mode 100644 index 00000000..c8e27a5b Binary files /dev/null and b/docs/assets/images/right top.png differ diff --git a/docs/assets/images/running app.png b/docs/assets/images/running app.png new file mode 100644 index 00000000..b2ed14bd Binary files /dev/null and b/docs/assets/images/running app.png differ diff --git a/docs/assets/images/saving.png b/docs/assets/images/saving.png new file mode 100644 index 00000000..b642bb6a Binary files /dev/null and b/docs/assets/images/saving.png differ diff --git a/docs/assets/images/screen.png b/docs/assets/images/screen.png new file mode 100644 index 00000000..2e3d0560 Binary files /dev/null and b/docs/assets/images/screen.png differ