mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
Update examples/readimage.js for readImageAsync.
This commit is contained in:
parent
bc62d03f84
commit
862cb7f777
@ -7,7 +7,6 @@ var imgdata = fs.readFileSync("./files/mona.png");
|
||||
|
||||
|
||||
|
||||
|
||||
var img = cv.readImage("./files/mona.png");
|
||||
console.log('Synchronous readImage("./files/mona.png")'+img.width()+'x'+img.height());
|
||||
|
||||
@ -56,3 +55,57 @@ cv.readImage(imgdata, 1, function(err, im){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// try with readImageAsync
|
||||
console.log('Now with readImageAsync');
|
||||
|
||||
img = cv.readImageAsync("./files/mona.png");
|
||||
console.log('Synchronous readImageAsync("./files/mona.png")'+img.width()+'x'+img.height());
|
||||
|
||||
cv.readImageAsync("./files/mona.png", function(err, im){
|
||||
console.log('Asynchronous callback readImageAsync("./files/mona.png", fn(){})'+im.width()+'x'+im.height());
|
||||
});
|
||||
|
||||
img = cv.readImageAsync( 100, 100 );
|
||||
console.log('Synchronous readImageAsync(100, 100) (create mat)'+img.width()+'x'+img.height()+' type '+img.type());
|
||||
|
||||
cv.readImageAsync(100, 100, function(err, im){
|
||||
console.log('!!Synchronous!! callback readImageAsync(100, 100, fn(){}) (create mat)'+im.width()+'x'+im.height());
|
||||
});
|
||||
|
||||
img = cv.readImageAsync(imgdata);
|
||||
console.log('Synchronous readImageAsync(imgdata:Buffer)'+img.width()+'x'+img.height());
|
||||
|
||||
cv.readImageAsync(imgdata, function(err, im){
|
||||
console.log('Asynchronous callback readImageAsync(imgdata:Buffer, fn(){})'+im.width()+'x'+im.height());
|
||||
});
|
||||
|
||||
|
||||
|
||||
// try with flags now
|
||||
console.log('Now Async with flags');
|
||||
|
||||
img = cv.readImageAsync("./files/mona.png", 0);
|
||||
console.log('Synchronous readImageAsync("./files/mona.png", 0) (monochrome)'+img.width()+'x'+img.height()+' type '+img.type());
|
||||
|
||||
cv.readImageAsync("./files/mona.png", 1, function(err, im){
|
||||
console.log('Asynchronous callback readImageAsync("./files/mona.png", 1, fn(){}) (colour)'+im.width()+'x'+im.height()+' type '+im.type());
|
||||
});
|
||||
|
||||
img = cv.readImageAsync( 100, 100, cv.Constants.CV_8UC3 );
|
||||
console.log('Synchronous readImageAsync(100, 100, cv.Constants.CV_8UC3) (create 8 bit 3 channel mat)'+img.width()+'x'+img.height()+' type '+img.type());
|
||||
|
||||
cv.readImageAsync(100, 100, cv.Constants.CV_8UC1, function(err, im){
|
||||
console.log('!!Synchronous!! callback readImageAsync(100, 100, cv.Constants.CV_8UC1, fn(){}) (create mat)'+im.width()+'x'+im.height()+' type '+im.type());
|
||||
});
|
||||
|
||||
img = cv.readImageAsync(imgdata, 0);
|
||||
console.log('Synchronous readImageAsync(imgdata:Buffer, 0) (monochrome)'+img.width()+'x'+img.height()+' type '+img.type());
|
||||
|
||||
cv.readImageAsync(imgdata, 1, function(err, im){
|
||||
console.log('Asynchronous callback readImageAsync(imgdata:Buffer, 1, fn(){}) (colour)'+im.width()+'x'+im.height()+' type '+im.type());
|
||||
});
|
||||
|
||||
console.log('\nTruely Async callbacks should be after this line\n');
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user