Updated the code that allows to save the cropped image in result_img directory#7282
Updated the code that allows to save the cropped image in result_img directory#7282shubham-shahh wants to merge 17 commits intoAlexeyAB:masterfrom
Conversation
|
I have updated your initial message and reopened initial issue. The magic token "Fixes: #issue" will close the issue if/when this PR is merged automatically |
okay, thanks :) |
committed the changes suggested Co-authored-by: Stefano Sinigardi <stesinigardi@hotmail.com>
|
@AlexeyAB what's your opinion on this PR? It fixes lines of code that are commented, as such they do not break nor fix anything. But, if the user was to uncomment those lines, they were broken and now ok |
@cenit sir please review my recent changes, in which I've added this feature. |
README.md
Outdated
| * To check accuracy mAP@IoU=50: `darknet.exe detector map data/obj.data yolo-obj.cfg backup\yolo-obj_7000.weights` | ||
| * To check accuracy mAP@IoU=75: `darknet.exe detector map data/obj.data yolo-obj.cfg backup\yolo-obj_7000.weights -iou_thresh 0.75` | ||
| * To save the cropped image of the object detected: [`uncomment the following lines of code`](https://github.com/AlexeyAB/darknet/blob/master/src/image_opencv.cpp#L980-L996) | ||
| * To run inference on all the images in a folder: `./darknet detector test ./cfg/coco.data ./cfg/yolov4.cfg ./yolov4.weights -i 0 -thresh 0.25 --folder_inference ./result_img/` here `./result_img/` is the path of the folder in which the inference has to be done. the folder name can be anything, as long as it exists. After the inference the images will be moved to `./processed_files/`. To change the folder name or path, the changes cane be done [`here`](https://github.com/shubham-shahh/darknet/blob/ebc7b6f3d575402fbcd67cf214243d437f580fe1/src/detector.c#L1895). |
There was a problem hiding this comment.
As always, please use links to alexeyab's repo, without any commit id reference but pointing to the latest master trunk
There was a problem hiding this comment.
Sir, I've updated the link but it is broken until the PR is merged @cenit
There was a problem hiding this comment.
Yes of course link is broken until merged, but this is a requirement for being considered for merging!
| if (lk.type == YOLO || lk.type == GAUSSIAN_YOLO || lk.type == REGION) { | ||
| l = lk; | ||
| printf(" Detection layer: %d - type = %d \n", k, l.type); | ||
| if(folder_inference==NULL){ |
There was a problem hiding this comment.
made changes in such a way that the original functionality is not changed by any means
|
But why is This |
Hello sir, I hope you are doing well.
thanks for this awesome project @AlexeyAB |
|
I think it is not worth to complicate the code due to the functionality that is easily achieved by these functions.
|
Sir, The procedure you mentioned is still terminating and the only way I can think of to make it non terminating is by creating a shell script that creates .txt files after every regular interval or to edit the code. In this approach, the user also has to make another .txt file to keep a track of images on which the inference has been done or delete the images or move them which again requires editing the code or putting that in a shell script. with this approach, |
|
./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights -ext_output -dont_show -out result.json < filelist.txt > result.txt NB! |
What are you trying to say? Can you please clearly describe your issue? |
I want to get the coordinates,then I use this commad, but I found the file only saved relative coordinates,while I want to save the absolute coordinates, do you know how to realize it? thanks |
|
Hi, can you try following code
pull request created for the same |
You can get the absolute co ordinates since you already know the original image size |
Can you clearly mention what exactly you're expecting? Thanks |
shubham-shahh
left a comment
There was a problem hiding this comment.
@cenit what does this commit do?
@shubham-shahh as you mentioned at top of this page, you are trying to crop detections out of image. I just provided a simple way of doing that. As you pointed out, " The type of 'show_img' has been changed from 'iplimage' to 'cv::Mat' ", so just crop the detected area out of original image. For that I have just added following single line -: |
| // if(copy_img == NULL) copy_img = cvCreateImage(cvSize(show_img->width, show_img->height), show_img->depth, show_img->nChannels); | ||
| // cvCopy(show_img, copy_img, 0); | ||
| // if(copy_img == NULL) copy_img = cvCreateImage(cvSize(ipltypeimg->width, ipltypeimg->height), ipltypeimg->depth, ipltypeimg->nChannels); | ||
| // cvCopy(ipltypeimg, copy_img, 0); |
H
Hi, this PR also implements some more features along with solving that bug. That bug is simply solved by converting the image to ipltype, I tagged you where I have done that conversion. Rest changes of this PR are made to implement several other features Thanks |
In that case, you may either exactly mention in title of this pull request or you may want to create different pull request for the bug and a different one for features implemented. That would provide more clarity to your pull request. If possible, provide appropriate title to your pull request, what bug it solves or what feature it implements and add changes necessary for that only in that particular pull request. Else, as I mentioned above, for the problem mentioned in the title, my changes are good enough. |
Hi, thanks |
| #include "box.h" | ||
| #include "demo.h" | ||
| #include "option_list.h" | ||
| #include <dirent.h> |
There was a problem hiding this comment.
PR is using dirent.h and code that is not cross-compatible, so is unacceptable as is
There was a problem hiding this comment.
can you please tag what part of the code which is causing issue? I will work on it. plus this is a really old PR it needs rebasing as well
There was a problem hiding this comment.
I rebased it on latest master for you before commenting the issue
There was a problem hiding this comment.
just rewrite the code in this file avoiding dirent.h inclusion (not available on windows)
There was a problem hiding this comment.
okay, thanks for pointing out the issues, I'll work on them
| DIR *folder; | ||
| struct dirent *entry; |
There was a problem hiding this comment.
these two lines, for example, depend on dirent.h being included, which is incompatible with our aim of being 100% windows compatible
There was a problem hiding this comment.
okay, I noted it, I'll apply required changes
There was a problem hiding this comment.
what's your opinion for Boost filesystem? I don't have much experience in building projects in windows. all your help is appreciated
There was a problem hiding this comment.
if you can use std::filesystem it would be much better, so that we can avoid depending on another external lib
There was a problem hiding this comment.
Okay, I'll look into it
thanks
There was a problem hiding this comment.
Hi, @cenit I was planning to fix this PR, I just wanted to know if there are any other changes to make other than filesystem?
|
Hi @cenit looks like you've fixed the issue related to building in windows, can we merge this PR into master? |
Bug Fix
updated based on the above conversion which was causing errors while recompiling the code.
So, I've updated that, and now one can store the detected images in result_img dir. I've also updated the Readme.md based
on that
Fixes: How to get co-ordinates and save image of the objects #7276
Feature Addition