tinycodinglm / ai /ai-0004.jsonl
winapiadmin's picture
Upload folder using huggingface_hub
1f3a244 verified
|
Raw History Blame Contribute Delete
1.83 kB
{"type": "session", "harness": "deepseek-harness", "id": "ai-0004", "name": "Computer Vision with OpenCV"}
{"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}}
{"type": "message", "message": {"role": "user", "content": "How do I do computer vision with OpenCV?"}}
{"type": "message", "message": {"role": "assistant", "content": "```python\nimport cv2\nimport numpy as np\n\n# Read/display image\nimg = cv2.imread('image.jpg')\ncv2.imshow('Image', img)\ncv2.waitKey(0)\n\n# Resize, crop, flip\nresized = cv2.resize(img, (224, 224))\ncropped = img[100:300, 100:300]\nflipped = cv2.flip(img, 1)\n\n# Color conversion\ngray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)\nhsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)\n\n# Edge detection\nedges = cv2.Canny(gray, 50, 150)\n\n# Face detection (Haar cascade)\nface_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')\nfaces = face_cascade.detectMultiScale(gray, 1.3, 5)\nfor (x, y, w, h) in faces:\n cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)\n\n# Object detection (DNN)\nnet = cv2.dnn.readNet('yolov3.weights', 'yolov3.cfg')\nblob = cv2.dnn.blobFromImage(img, 0.00392, (416, 416), (0, 0, 0), True, crop=False)\nnet.setInput(blob)\ndetections = net.forward(output_layers)\n\n# Video processing\ncap = cv2.VideoCapture(0)\nwhile True:\n ret, frame = cap.read()\n cv2.imshow('Video', frame)\n if cv2.waitKey(1) & 0xFF == ord('q'):\n break\ncap.release()\n```"}}