我有一个用python,opencv和ffmpeg构建的网络摄像头录像机程序
除了视频的颜色比现实更蓝,它才能正常工作.问题似乎来自图像的颜色格式.
似乎OpenCv正在提供BGR图像,而ffmpeg + libx264正在期待YUV420p.我读过YUV420p对应YCbCr.
opencv没有从BGR到YCbCr的转换.它只转换为YCrCb.
我做了一些搜索并尝试了不同的替代方案,尝试将opencv图像转换为ffmpeg + libx264可以正常的东西.没有工作.在这一点上,我有点迷失,我会感谢任何可以帮助我解决这个颜色问题的指针.
可能重复:
指向特定固定地址的指针
关于这一点的有趣讨论从这里开始,但没有人能够提供C++的做法:
#include <stdio.h>
int main(void)
{
int* address = (int *)0x604769;
printf("Memory address is: 0x%p\n", address);
*address = 0xdead;
printf("Content of the address is: 0x%p\n", *address);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
在C++中做这样事情最合适的方法是什么?
我已经安装了OpenCV 2.2,现在我无法使网络摄像头捕获工作.它在2.1中运行正常.OpenCV检测到网络摄像头,不报告任何错误或警告,但每个帧都是灰色图像.我甚至尝试过OpenCV wiki的代码示例:
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
Mat edges;
namedWindow("edges",1);
for(;;)
{
Mat frame;
cap >> frame; // get a new frame from camera
cvtColor(frame, edges, CV_BGR2GRAY);
//GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
//Canny(edges, edges, 0, 30, 3);
imshow("edges", edges);
if(waitKey(30) >= 0) break;
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
Run Code Online (Sandbox Code Playgroud)
有人遇到过这个问题吗?我使用的是64位Win7和Visual Studio 2010.
我有问题将String时间转换为Time对象,因为它与Date一起打印.这是我的代码.
String time = "15:30:18";
DateFormat sdf = new SimpleDateFormat("hh:mm:ss");
Date date = sdf.parse(time);
System.out.println("Time: " + date);
Run Code Online (Sandbox Code Playgroud)
如何转换和打印时间只有没有日期在java中.如果你能举一个例子会更好.
谢谢.
我在xubuntu上使用eclipse CDT.它完美地运作.唯一的问题是,当您将鼠标放在变量上时出现的弹出框的背景颜色将具有黑色的背景颜色.
有时,此框中的某些文字也会是黑色的.然后我必须选择框内的所有文字来阅读那里的内容.对于我的生活,我无法弄清楚在哪里改变背景黑色......
这里有人知道也许请.
我想在全屏无边框窗口中在OpenCV中显示图像.换句话说,只显示图像像素,没有菜单,工具栏或窗口背景.
使用imshow()
或cvShowImage()
不启用它:
我认为问题的根源在于cvNamedWindow()
创建主WS_OVERLAPPED
窗口的方法,然后创建一个子项以及所有函数imshow()
或者cvGetWindowHandle()
对子项进行操作.
因此即使是windows命令:
SetWindowLong((HWND)cvGetWindowHandle(winName), GWL_STYLE, WS_VISIBLE | WS_EX_TOPMOST | WS_POPUP);
Run Code Online (Sandbox Code Playgroud)
没有帮助,因为孩子不能无国界WS_POPUP
.有人得到了解决方法吗?
PS我尝试了以下代码:
cvMoveWindow("AAA",0,0);
cvSetWindowProperty("AAA", CV_WINDOW_FULLSCREEN, CV_WINDOW_FULLSCREEN);
// Also I tried this:
HWND hwnd = (HWND)cvGetWindowHandle("AAA");
RECT windowRect;
windowRect.left = 0;
windowRect.top = 0;
windowRect.right = cxScreen; //Display resolution
windowRect.bottom = cyScreen; //Display resolution
AdjustWindowRect(&windowRect,WS_VISIBLE,false);
long p_OldWindowStyle = SetWindowLongPtr(hwnd,GWL_STYLE,WS_POPUP);
SetWindowPos(hwnd,HWND_TOP,0,0,windowRect.right,windowRect.bottom,SWP_FRAMECHANGED | SWP_SHOWWINDOW);
SetWindowLong(hwnd, GWL_STYLE, WS_VISIBLE | WS_EX_TOPMOST | WS_POPUP);
Run Code Online (Sandbox Code Playgroud) 马尔可夫随机字段是一种非常流行的图像查看方式,但我找不到直接引用它们在OpenCV中实现.也许它们的名称不同,或者是通过某种间接方法构建的.
正如标题所述,是否在OpenCV中实施了MRF?如果没有,代表他们的流行方式是什么?
我完全按照这个教程提到了这里
我现在尝试在Visual Studio上运行简单的OpenCV代码,但我不断收到链接器错误.我正在尝试这个OpenCV 教程
这是我一直得到的错误:
1>Linking...
1>LINK : warning LNK4067: ambiguous entry point; selected 'mainCRTStartup'
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "int __cdecl cv::waitKey(int)" (?waitKey@cv@@YAHH@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "void __cdecl cv::imshow(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class cv::_InputArray const &)" (?imshow@cv@@YAXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@ABV_InputArray@1@@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external symbol "public: __thiscall cv::_InputArray::_InputArray(class cv::Mat const &)" (??0_InputArray@cv@@QAE@ABVMat@1@@Z) referenced in function _main
1>OpenCV_Proj.obj : error LNK2019: unresolved external …
Run Code Online (Sandbox Code Playgroud) 目前我正在开发图像处理项目,我正在使用javacv开发图像处理组件.我能够提取图像的一些有趣部分,现在我需要读取这些对象的x和y坐标.这是我提取的图像
我需要识别这些对象并围绕这些对象绘制正方形.我浏览了一些教程并尝试使用以下代码识别对象.
IplImage img="sourceimage";
CvSize sz = cvSize(img.width(), img.height());
IplImage gry=cvCreateImage(sz, img.depth(), 1);
cvCvtColor(img, gry, CV_BGR2GRAY);
cvThreshold(gry, gry, 200, 250, CV_THRESH_BINARY);
CvMemStorage mem = CvMemStorage.create();
CvSeq contours = new CvSeq();
CvSeq ptr = new CvSeq();
cvFindContours(gry, mem, contours, Loader.sizeof(CvContour.class) , CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
CvRect boundbox;
for (ptr = contours; ptr != null; ptr = ptr.h_next()) {
boundbox = cvBoundingRect(ptr, 0);
if(boundbox.height()>10||boundbox.height()>10){
cvRectangle( gry, cvPoint( boundbox.x(), boundbox.y() ), cvPoint( boundbox.x() + boundbox.width(), boundbox.y() + boundbox.height()),CvScalar.BLUE, 0, 0, 0 );
System.out.println(boundbox.x()+", "+boundbox.y()); …
Run Code Online (Sandbox Code Playgroud) 我试图检测两个白色墙壁上的红色墙壁和白色方块的图像中的位置,红色顶部和白色"柱子":
我的方法是进行阈值处理以找到我现在可以从输出中轻松检测到的红色墙壁:
现在我的问题是检测白色方块的位置,但考虑到白色墙壁,这更难.如果我基于白色的阈值,我仍然在白色方柱之间保留不需要的白色墙壁.
任何帮助将不胜感激.