Open sumansingh-coder opened 2 months ago
Thank you for sharing the details. It looks like you're encountering an issue with your ONNX model in OpenCV. Please ensure you are using the latest version of YOLOv5 and OpenCV. Additionally, verify that your ONNX model is correctly exported. If the issue persists, please provide more details about the error message. For further guidance, you can refer to the YOLOv5 documentation.
Search before asking
YOLOv5 Component
No response
Bug
Tried onnx version 17 and version 12 still the same error
Here is the code
include
include <opencv2/opencv.hpp>
std::vector load_class_list()
{
std::vector class_list;
std::ifstream ifs("/home/suman-singh/Downloads/yolov5-master/temp.txt");
std::string line;
while (getline(ifs, line))
{
class_list.push_back(line);
}
return class_list;
}
void load_net(cv::dnn::Net &net, bool is_cuda) { auto result = cv::dnn::readNet("/home/suman-singh/Downloads/yolov5-master/yolov5s.onnx"); if (is_cuda) { std::cout << "Attempty to use CUDA\n"; result.setPreferableBackend(cv::dnn::DNN_BACKEND_CUDA); result.setPreferableTarget(cv::dnn::DNN_TARGET_CUDA_FP16); } else { std::cout << "Running on CPU\n"; result.setPreferableBackend(cv::dnn::DNN_BACKEND_OPENCV); result.setPreferableTarget(cv::dnn::DNN_TARGET_CPU); } net = result; }
const std::vector colors = {cv::Scalar(255, 255, 0), cv::Scalar(0, 255, 0), cv::Scalar(0, 255, 255), cv::Scalar(255, 0, 0)};
const float INPUT_WIDTH = 640.0; const float INPUT_HEIGHT = 640.0; const float SCORE_THRESHOLD = 0.2; const float NMS_THRESHOLD = 0.4; const float CONFIDENCE_THRESHOLD = 0.4;
struct Detection { int class_id; float confidence; cv::Rect box; };
cv::Mat format_yolov5(const cv::Mat &source) { int col = source.cols; int row = source.rows; int _max = MAX(col, row); cv::Mat result = cv::Mat::zeros(_max, _max, CV_8UC3); source.copyTo(result(cv::Rect(0, 0, col, row))); return result; }
void detect(cv::Mat &image, cv::dnn::Net &net, std::vector &output, const std::vector &className) {
cv::Mat blob;
}
int main(int argc, char **argv) {
}
Environment
No response
Minimal Reproducible Example
i want my webcam to open and take video but it closes immediately
Additional
Plzz help fast
Are you willing to submit a PR?