对于STDIN_FILENO和STDOUT_FILENO,非阻塞I / O行为很奇怪(nonblocking I/O behavior is weird for STDIN_FILENO and STDOUT_FILENO)
我有以下代码:
void set_fl(int fd, int flags) /* flags are file status flags to turn on */ { int val; if ((val = fcntl(fd, F_GETFL, 0)) < 0) err_sys("fcntl F_GETFL error"); val |= flags; /* turn on flags */ if (fcntl(fd, F_SETFL, val) < 0) err_sys("fcntl F_SETFL error"); } int main(void) { char buf[BUFSIZ]; set_fl(STDOUT_FILENO, O_NONBLOCK); //set STDOUT_FILENO to nonblock if(read(STDIN_FILENO, buf, BUFSIZ)==-1) { //read from STDIN_FILENO printf("something went wrong with read()! %s\n", strerror(errno)); } }
如您所见,我将
STDOUT_FILENO
设置为非阻塞模式,但似乎STDIN_FILENO
上的读操作立即完成。 为什么?$ ./testprog something went wrong with read()! Resource temporarily unavailable
谢谢
I have the following code:
void set_fl(int fd, int flags) /* flags are file status flags to turn on */ { int val; if ((val = fcntl(fd, F_GETFL, 0)) < 0) err_sys("fcntl F_GETFL error"); val |= flags; /* turn on flags */ if (fcntl(fd, F_SETFL, val) < 0) err_sys("fcntl F_SETFL error"); } int main(void) { char buf[BUFSIZ]; set_fl(STDOUT_FILENO, O_NONBLOCK); //set STDOUT_FILENO to nonblock if(read(STDIN_FILENO, buf, BUFSIZ)==-1) { //read from STDIN_FILENO printf("something went wrong with read()! %s\n", strerror(errno)); } }
As you can see, I set
STDOUT_FILENO
to non-blocking mode but it seems the read operation onSTDIN_FILENO
finished immediately. Why?$ ./testprog something went wrong with read()! Resource temporarily unavailable
Thanks
原文:https://stackoverflow.com/questions/9676991
最满意答案
该错误消息看起来像是一个图像像素超出了您的HoG窗口区域。
据我所知,HoG描述符具有某种“winSize”属性(例如,人物描述符afair为64x128像素)。
通过调整图像大小或选择相关的子区域,确保图像适合描述符窗口大小!
The error message looks like an images pixel is out of your HoG window area.
As far as I know, HoG Descriptors have some kind of "winSize" property (e.g. 64x128 pixel for the people descriptor afair).
Make sure that your image fits the descriptor window size by resizing the image or selecting the relevant sub-area!
相关问答
更多-
OpenCV文件存储错误(OpenCV filestorage error)[2023-05-06]
你的代码是正确的(除了你重新定义FileStorage fs... ,只是改变名称)。 通常,如果在OpenCV中有Unhandled exception错误,这意味着您在发行版中使用了调试库,反之亦然。 从评论中可以看出,这实际上是个问题。 请确保仅链接到Release中的opencv_world310d.lib和Debug中的opencv_world310d.lib 。 Your code is correct (aside that you redefine FileStorage fs..., ju ... -
我相信@Micka是对的:直方图可能正常化(可能不是1)。 在HOG描述符的维基百科页面上 ,写道: 为了提高准确度,可以通过计算图像的较大区域(称为块)上的强度的度量,然后使用该值来标准化块内的所有单元,来对比度标准化局部直方图。 这种归一化导致更好的照明和阴影变化的不变性。 因此需要vector
而不是vector 。 I believe that @Micka is right: the histograms are probably normalized (maybe not ... -
我想到了。 我做错了几件事 我正在训练图像而不是features 我忘了在支持向量中添加-rho 首先,我创建了一个2d float array 。 使用HOGDescriptor类中的compute函数使用图像的功能填充它。 用阵列训练SVM。 在训练之后,我使用getDecisionFunction函数来获取rho并将其附加到supportvector 。 I figured it out. I was doing a couple thing wrong I was training with ima ...
-
为什么不尝试与python示例中相同的东西? Mat img = ... Mat descr; hog.compute(img, descr, ...); float eps = 1e-7f; descr /= sum(descr)[0] + eps; // same as: normalize(descr,descr,1,eps,NORM_L1); sqrt(descr,descr); descr /= norm(descr) + eps; // ... feed to svm why not ...
-
您正在错误地初始化HOGDescriptor 。 断言声明前三个输入参数中的每一个都必须满足约束: (winSize - blockSize) % blockStride == 0 height和width尺寸。 问题是winSize.height不满足这个约束,考虑到你初始化hog的其他参数: (412 - 16) % 8 = 4 //Problem!! 可能最简单的解决方法是将窗口尺寸从cv::Size(320,412)增加到可被8整除的东西,可能是cv::Size(320,416) ,但具体 ...
-
该错误消息看起来像是一个图像像素超出了您的HoG窗口区域。 据我所知,HoG描述符具有某种“winSize”属性(例如,人物描述符afair为64x128像素)。 通过调整图像大小或选择相关的子区域,确保图像适合描述符窗口大小! The error message looks like an images pixel is out of your HoG window area. As far as I know, HoG Descriptors have some kind of "winSize" pr ...
-
在OpenCV中训练自定义SVM以与HOGDescriptor一起使用(Training custom SVM to use with HOGDescriptor in OpenCV)[2022-01-10]
在线性svm训练之后,我编写了一个CvSVM的子类来提取原始形式。 阳性样品标记为1,阴性样品标记为-1。 奇怪的是,为了从HogDescriptor获得正确的结果,我必须在alphas前加上负号并保持rho的符号不变。 LinearSVM.h #ifndef LINEAR_SVM_H_ #define LINEAR_SVM_H_ #include#include class LinearSVM: public Cv ... -
OpenCv中的错误(Error In OpenCv)[2023-09-07]
从评论到问题,结果是OP连接到OpenCV 2.4.8,而不是OpenCV 3.0.0。 更正链接的库名称以及库路径,解决了该问题。 From the comments to the question it turned out that the OP was linking to OpenCV 2.4.8, instead of OpenCV 3.0.0. Correcting the linked libraries name, as well as the library path, solved t ... -
没有必要自己执行额外的转换,这个问题与新旧OpenCV绑定的混合有关。 关于hog.detectMultiScale的另一个问题hog.detectMultiScale是由于参数排序不正确。 通过检查help(cv2.HOGDescriptor().detectMultiScale)可以直接看到第二个问题: detectMultiScale(img[, hitThreshold[, winStride[, padding[, scale[, finalThreshold[, useM ...
-
我已经解决了这个问题! 我改变了...... cv::HOGDescriptor body; 至... cv::CascadeClassifier body; 它就像一个魅力! :) I've resolved this problem! I've changed... cv::HOGDescriptor body; to... cv::CascadeClassifier body; and it works like a charm! :)