Convert a frame into image and use it as an input elsewhere
7 ビュー (過去 30 日間)
古いコメントを表示
I want to convert a frame into an image file. I am using the following code to acquire the frame, now i want to use that frame as an image file in my code, need help with that.. the code is
--------------
vid = videoinput('winvideo',1);
set(vid,'ReturnedColorSpace','rgb')
frame= getsnapshot(vid);
%here i want to take this frame as input image
input='frame';
.
.
--------------
but i am getting the following error
---------
??? Error using ==> strfind
Input strings must have one row.
Error in ==> imread at 296
if (strfind(filename, '://'))
-------------
Please help me with this. or direct me to other solution
0 件のコメント
回答 (2 件)
Walter Roberson
2012 年 5 月 3 日
If you are going to imread() the image, you need to first imwrite() the frame into an image file.
2 件のコメント
Walter Roberson
2012 年 5 月 3 日
imwrite(frame.cdata, frame.map, TheFileName);
where TheFileName is a string the specifies the name of the file to write.
Image Analyst
2012 年 5 月 3 日
I'm not sure why you called imread() instead of just using the "frame" array directly in your subsequent code. If you want to use imread, then show your code for both imwrite and imread, but it's not really necessary unless you want to save the image to disk for some reason. Even if you did, you can continue to use "frame" and don't need to call imread at all.
3 件のコメント
Image Analyst
2012 年 5 月 3 日
But they're not using getframe(), they're using getsnapshot() which does return an image out of the video stream just like any other image. It can be saved with imwrite(), or displayed with imshow(). I do it all the time. Here's a snippet of code from an m-file I'm working on today:
% Snap picture from camera.
if isempty(vidobj), return, end;
snappedImage = getsnapshot(vidobj); % This works.
imshow(snappedImage);
Walter Roberson
2012 年 5 月 3 日
Ah yes, I misread. (Can I blame it on the tail end of the cold I have?)
参考
カテゴリ
Help Center および File Exchange で Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!